Note that there are some explanatory texts on larger screens.

plurals
  1. POMoving sprite from a group of sprites
    primarykey
    data
    text
    <p>I am having 15 sprites in my layer.i added these sprite to mutable array i want to move single sprite using <code>ccTouchesMoved</code>.when the touch ended <code>ccTouchesEnded</code> sprite move back to its starting point or its origin.</p> <p>My coding:</p> <pre><code>if( (self=[super init])) { collection=[[NSMutableArray alloc]init]; CCLayer *base=[CCSprite spriteWithFile:@"Base.png"]; base.position=ccp(512,384); [self addChild:base]; x=0; for(int i=1;i&lt;=7;i++) { CCSprite *hole=[CCSprite spriteWithFile:@"ball.png"]; hole.position=ccp(140+x,318); hole.tag=i; [self addChild:hole]; hole.visible=YES; [collection addObject:hole]; x=x+75; } self.isTouchEnabled=YES; } return self; } -(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch=[touches anyObject]; CGPoint location=[touch locationInView:[touch view]]; location=[[CCDirector sharedDirector]convertToGL:location]; location=[self convertToNodeSpace:location]; p=location; } -(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"count:%i",[collection count]); UITouch *touch=[touches anyObject]; CGPoint location=[touch locationInView:[touch view]]; location=[[CCDirector sharedDirector]convertToGL:location]; location=[self convertToNodeSpace:location]; for(CCSprite *s in collection) { if(CGRectContainsPoint([s boundingBox], location)) s.position=ccp(location.x,location.y); } } -(void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { for(CCSprite *s in collection) { s.position=p; } } </code></pre> <p>when i moving one sprite other sprites also visible on the layer not to be hide. please help me with code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload