I got an issue with the positioning code. I got 4 objects, lets call them Obj1 Obj2 Obj3 Obj4. I want them to spawn on the right side of the screen, moving to the left site of the screen, and than disappear. Obj 1 and Obj 2 are on the same y position, Obj 3 should be a little bit higher like + 40 y, and Obj 4 should be the only one with a mobile y position.
Obj 1 , 2 and 3 need to have a x gap between them, while Obj 4 can be random.
I can code every single outcome of it, for eg. =
int Obj1x = 320;
int Obj1y = 200;
Obj1.position = CGPointMake(Obj1x, Obj1y);
int Obj2x = 0;
int Obj2y = 0;
int r1 = arc4random() % 2; // produces random numbers between 0 and 1
if(r1 == 0)
Obj2x = Obj1x + 80;
if(r1 == 1)
Obj2x = Obj1x + 100;
int r2 = arc4random() % 1;
if(r2 == 0)
Obj2y = Obj1y;
Obj2.position = CGPointMake(Obj2x, Obj2y);
This way, it would take too much to write every outcome for it. Is there any other way to code it? Thank you very much.