Curnelious
Curnelious

Reputation: 1

calling a scene in cocos2d is fire init method?

i use cocos2d in xcode. when i call from xcode class to a cocos class(scene) function, it fires the init method, BUT i want to fire only the spesific function that i call, because the init was already fired at the start of the animation ...

how to do that ?

HelloWorld *ran=[[HelloWorld alloc] init];
    [ran HardwareEvent:DollPart];

the cocos2d class name that i call is is HelloWorldScene. how can i call a function and not fire init ?

Thanks..

Upvotes: 0

Views: 360

Answers (1)

ScottPetit
ScottPetit

Reputation: 814

I'm assuming you've already called init on HelloWorld from withing your current scene. If that's the case then I'd create a variable in the .h to access HelloWorld throughout your current scene. In your .h it would look something like:

HelloWorld *helloWorld

This would change the other time that you called init on your HelloWorld scene to just be

helloWorld = [[HelloWorld alloc] init];

and should allow you to call the HardwareEvent: DollPart: method by just calling

[helloWorld HardwareEvent:DollPart];

Upvotes: 1

Related Questions