Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that when you call performSelector there are only two options:</p> <ol> <li>have your selector take no arguments and leave the ":" off the @selector(foo) definition.</li> <li>have your selector take either one or two arguments <strong>which both must be an NSObject or subclass</strong></li> </ol> <p>it is the latter that is messing you up here I suspect.</p> <p>Here are the three forms of <code>performSelector</code>:</p> <pre><code>- (id)performSelector:(SEL)aSelector; - (id)performSelector:(SEL)aSelector withObject:(id)object; - (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2; </code></pre> <p>You'll note that the withObject arguments are all of type <code>id</code> which is an Objective C object.</p> <p>The selector you're trying to use takes a <code>ccTime</code> which is a <code>float</code> and <strong>not</strong> an Objective C object as it's param and that is why things are crashing:</p> <pre><code>-(void)rotate:(ccTime)delta; </code></pre> <p>One option is to make a wrapper method that takes a wrapped <code>ccTime</code> and unwraps it and calls the <code>rotate:(ccTime)</code> method:</p> <pre><code>- (void) wrappedRotate: (NSNumber*) inDelta { [self rotate: [inDelta floatValue]]; } </code></pre> <p>then use</p> <pre><code>selectors[0] = @selector(wrappedRotate:); </code></pre> <p>and then call via:</p> <pre><code>[self schedule: @selector(moveThings:)]); // cocos2d schedule ... - (void) moveThings: (ccTime) dt { [self performSelector: selectors[0] withObject: [NSNumber numberWithFloat: dt]]; ... } </code></pre> <p>One reason you are getting confused is because Cocos2d is using @selector in somewhat more complicated ways (see CCScheduler.m in the CCTimer::initWithTarget:selector:interval: and CCTimer::update: method in particular).</p> <p>disclaimer: code typed into SO so not checked with a compiler, but the essence of what you need should be here.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload