Wednesday 15 May 2013

sprite kit - SKAction Perform Selector syntax error -



sprite kit - SKAction Perform Selector syntax error -

using skaction sequence trying add together delay , phone call method 2 parameters, maintain getting next (new obj c simple):

// code skaction *fireaction = [skaction sequence:@[[skaction waitforduration:1.5 withrange:0], [skaction performselector:@selector(addexplosion:firstbody.node.position andthename: @"whiteexplosion") ontarget:self]]];

// error

expected ':'

method declaration

-(void) addexplosion : (cgpoint) position andthename :(nsstring *) explosionname{

when substitute method phone call without parameters seems work fine.

any input appreciated.

use [skaction runblock:^{}] instead of selector.

i utilize selectors if method has no parameters. using block much more powerful. beware of how utilize them may maintain expected deleted objects alive.

__weak typeof(self) weakself = self; skaction *fireaction = [skaction sequence:@[ [skaction waitforduration:1.5 withrange:0], [skaction runblock:^{ [weakself addexplosion:position andthename:explosionname]; }]]];

or utilize completion block:

__weak typeof(self) weakself = self; skaction *fireaction = [skaction waitforduration:1.5 withrange:0]; [somenode runaction:fireaction completion:^{ [weakself addexplosion:position andthename:explosionname]; }];

sprite-kit skaction

No comments:

Post a Comment