My Sprite comes out the screen
Posted
by
IlNero
on Game Development
See other posts from Game Development
or by IlNero
Published on 2012-09-16T22:04:58Z
Indexed on
2012/09/17
3:53 UTC
Read the original article
Hit count: 234
cocos2d-iphone
|cocos2d
If i an action moves the sprite,how can i keep the CCSprite on the screen???? this is my code:
[enemy runAction:[CCSequence actions:[CCMoveBy actionWithDuration:2.0 position:ccp(-winSize.width*0.4, 0)],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(winSize.width*0.2, -winSize.width*0.2),
randomValueBetween(winSize.height*0.2, -winSize.height*0.2))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(winSize.width*0.2, -winSize.width*0.2),
randomValueBetween(winSize.height*0.2, -winSize.height*0.2))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(winSize.width*0.2, -winSize.width*0.2),
randomValueBetween(winSize.height*0.2, -winSize.height*0.2))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(winSize.width*0.2, -winSize.width*0.2),
randomValueBetween(winSize.height*0.2, -winSize.height*0.2))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(winSize.width*0.2, -winSize.width*0.2),
randomValueBetween(winSize.height*0.2, -winSize.height*0.2))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(-winSize.width*0.3,winSize.width*0.3),
randomValueBetween(winSize.height*0.3, -winSize.height*0.3))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(-winSize.width*0.2,winSize.width*0.2),
randomValueBetween(winSize.height*0.2, -winSize.height*0.2))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(-winSize.width*0.3,winSize.width*0.3),
randomValueBetween(winSize.height*0.3, -winSize.height*0.3))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(-winSize.width*0.2,winSize.width*0.2),
randomValueBetween(winSize.height*0.2, -winSize.height*0.2))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(-winSize.width*0.3,winSize.width*0.3),
randomValueBetween(winSize.height*0.3, -winSize.height*0.3))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:randomValueBetween(1.0, 0.3)
position:ccp(randomValueBetween(-winSize.width*0.2,winSize.width*0.2),
randomValueBetween(winSize.height*0.2, -winSize.height*0.2))],
[CCDelayTime actionWithDuration:0.5],
[CCMoveBy actionWithDuration:2.0 position:ccp(-winSize.width*1.5, 0)],
[CCCallFuncN actionWithTarget:self selector:@selector(invisNode:)], nil]];
but whit this code the sprite sometimes comes out the screen, i need the sprite moves randomly in the screen without comes out..
© Game Development or respective owner