iphone - Cocos2d - how to make individual particles follow the layer, not the emitter? -
I have two children of a CCSprite and CCParticleSystemQuad that CCLayer. My update method, I have come to expect such exits from the bottom of the fairy would set the emitter's position, so it around phantom track the smoke puffs sprite like you and even if you Preth , Then the smoke appears to be part of the background layer.
The problem comes when I have their rotation. Now, for example, my Sprite works back and forth in an arc, then the smoke appears swing swing and attached with Sprite.
How can I continue with the parent layer in the puff of smoke, not walking with a straight line and sprite? They do not translate with the phantom when I take it, why do they wander with it?
Edit: Adding code ...
- (id) init {If (! (Self ([(super (init))) return zero; Self.isTouchEnabled = Yes; CGSize screen size = [[CCCceterShare Share Director]]; Phantom = [CCS light spread with file: @ "Icon page"]; // Header declared [Phantom set status: CCP (screen size. 2, screen size. High / 2)]; [Add soul to child: phantom]; ID repeatAction = [CCRepeatForever actionWithAction: [CCSequence action: [CCRotateTo actionWithDuration: 0.3f angle: -45.0f], [CCRotateTo actionWithDuration: 0.6f angle: 45.0f], [CCRotateTo actionWithDuration: 0.3f angle: 0.0f], zero] ]; [Phantom Run Action: Duplication]; Emitter = [[Maintenance of CCParticleSystemQuad particleWithFile: @ "jetpack_smoke.plist"]]; // Header declared - particle particle designer [Emitter set position: sprite.position] was made in; [Emitter setPositionType: kCCPositionTypeFree]; // ... Free and ... seem to behave in relative equities [emeter stop system]; [Self compound: emitter]; [Auto scheduling update]; Self return; } - (void) Update: (ccTime) dt {[setPosition emitter: CCP (sprite.position.x, sprite.position.y-sprite.contentSize.height / 2)]; [Emitter setRotation: [Phantom rotation]]; // If you comment on it, then it works as expected} // There are touching ways to touch the way to touch, where the touch occurs, and when the touch starts to start the emitter and To stop it while touching. I found the answer on another site - www.raywenderlich.com
I do not know that it's really why, but it seems that is not like the CCParticleSystems to move around while you move around them they have no problem in changing its angle property Actually, there are cases where you want this behavior. Still, I have made a method that adjusts the angle property of the emitter and it works fine. It moves to its touch location angle and measures the y component
- (zero) updateAngle:. (CGPoint) location {float width = [[CCDirector sharedDirector] winSize] .width; Float angle = location.x / width * 360.0f; CCalog (@ "angle =% 1.1f", angle); [Smoke meter angle: angle]; // I added smoke and fire both! [Fire-set setang: angle]; // [emitter setRotation: angle]; // it does not work}
Comments
Post a Comment