Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display sprites randomly on left and right side on iphone(portrait mode) using cocos2d?
    primarykey
    data
    text
    <p>I'm new to this cocos2d.I'm developing one game in iPhone using cocos2d in that i've to display sprites on left and right side on iPhone (portrait mode). I tried like this. array_obstacle is a ccarray containing obstacles. in first part I used array_obstacles as it is.In second part i scaled that sprite using same obstacles. Here I used two sprites for displaying sprites on left and right side on iphone(portrait mode). Now,I want to use only one sprite to display sprites on left and right side on iphone(portrait mode). can any one suggest me regarding this?</p> <pre><code>int ran = arc4random() % [array_obstacles count]; randomSprite = [CCSprite spriteWithSpriteFrameName:[array_obstacles objectAtIndex:ran]]; int minX = 250;//(winSize.width/2)-120; int maxX =300; //(winSize.width/2)+120; int rangeX = maxX - minX; int actualX = (arc4random() % rangeX) + minX; randomSprite.position = ccp( actualX,winSize.height+randomSprite.contentSize.width); [spriteSheetBatch addChild:randomSprite]; id actionMove2 = [CCMoveTo actionWithDuration:1.5 position:ccp(actualX,-randomSprite.contentSize.width)]; [randomSprite runAction:actionMove2]; int r = arc4random() % [array_obstacles count]; myRandomSprite = [CCSprite spriteWithSpriteFrameName:[array_obstacles objectAtIndex:r]];int min_X = -50;//(winSize.width/2)-120; int max_X =160; //(winSize.width/2)+120; int range_X = max_X +min_X; int actual_X = (arc4random() % range_X) + min_X; myRandomSprite.position = ccp( actual_X,winSize.height+myRandomSprite.contentSize.width); id actionMove1 = [CCMoveTo actionWithDuration:1.5 position:ccp(actual_X,-myRandomSprite.contentSize.width)]; myRandomSprite.scaleX = -1.0f; [myRandomSprite runAction:actionMove1]; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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