cclayer

Pinch to zoom with CCParallaxNode

心已入冬 提交于 2019-12-13 00:17:21
问题 How do I implement pinch to zoom to a parallax scrolling node ? 回答1: Here's the solution: - (void)handlePitchZoom:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch1 = [[[event allTouches] allObjects] objectAtIndex:0]; UITouch* touch2 = [[[event allTouches] allObjects] objectAtIndex:1]; // calculate scale value double prevDistance = ccpDistance([touch1 previousLocationInView:[touch1 view]], [touch2 previousLocationInView:[touch2 view]]); double newDistance = ccpDistance([touch1

How to transfer a CCSprite from one parent to another?

社会主义新天地 提交于 2019-12-12 11:18:27
问题 I have a CCSprite called sprite that is a child of a CCLayer called movingLayer that is itself a child of the current CCLayer running my game logic, so it is self in this case. movingLayer is moving back and forth across the screen in a repeat forever action and sprite is riding along on it. I want to get sprite to "get off" of movingLayer and "get on" to self where it can do some actions of its own. When I try to do this, I need to tell movingLayer to remove sprite and self to add sprite.

HUD layer not being added on my scene

狂风中的少年 提交于 2019-12-11 14:11:34
问题 I have a CCScene which already holds my gameLayer and I am trying to add HUD layer on that.But the HUD layer is not getting added in my scene, I can say that because I have set up a CCLabel on HUD layer and when I run my project, I cannot see that label. Here's what I am doing : In my gameLayer: +(id) scene { CCScene *scene = [CCScene node]; GameScreen *layer = [GameScreen node]; [scene addChild: layer]; HUDclass * otherLayer = [HUDclass node]; [scene addChild:otherLayer]; layer.HC =

Touch handled by two layers

家住魔仙堡 提交于 2019-12-11 04:19:40
问题 I have a CCLayer containing a number of other CCLayer s (like items of text etc). I have another CCLayer to the left hand side with which I want to display thumbnails of a number of these 'scenes'. The left hand CCScrollLayer should respond to touches which are within its bounds, while elements in the right hand layer should respond to touches inside their individual bounds. The problem I'm seeing is that when I drag for example a layer on the right, the CCScrollLayer to the left is