Tuesday 15 January 2013

Cocos2d animation on sprite and detect contact on him -


I know how to find contacts on all my sprites on the screen. I also know how the animation is played on the phantom forever.

But when the code is put together for animation, then with the phantom sheet - you actually add a phantom as a child, but only the phantom sheet has a phantom Is the child of the sheet.

  [[CCSprintFrankCachsharesprofifaMachet] Aadrophroughswithfile: @ "Perrott.plist"]; CCSpriteBatchNode * spriteSheet = [CCSpriteBatchNode batch nodewhitefile: @ "parat page"]; Fireball = [CCSlight Spit with AsprintFramemame: @ "Paper 1 Page"]; FireBall.position = point; [SpriteSheet addBild: fireBall]; [Add Your Child: Prasheette]; // Here is the fire from the animation action << code>  

In the situation when looking for fireball to detect the contact - you can not find it because She has not been added as a child of the scene, but of the phantom sheet.

How can I find out that phantom later on my code? Or is there a constellation to set the phantom sheet?

Thank you

You can

1) Create a property for your fireball

/ code> Phantom:

  @property (nonatomic, retain) CCSprite * fireball;   

and create and use self.fireball :

  self.fireBall = [CCSprite spriteWithSpriteFrameName: @ "parrot1] Use .png "]; ... CGPoint fireBallPosition = self.fireBall.position;   

2) Add fireball as a tag on the spriteSheet tag and get it back using the same tag. [spriteSheet addChild: fireBall z: 0] Tags: 1]; ... Fireball = [Get SpreadsheetsBybuTag: 1];

But keep in mind that the fireball position is relative to their parent, spriteSheet . Therefore, if you move the spriteSheet , you will also go to spriteSheet .

No comments:

Post a Comment