mercredi 25 février 2015

Randomly generating 3 letter dictionary words to emulator using sprites

I have three sprites that I want to randomly generate, all come in the form of pngs. I'm not sure how to store CCSprites in an array to compile as a word. (i.e. [p.png,a.png,r.png] which prints out par).


I have this so far:



rocket[0] = [CCSprite spriteWithImageNamed:@"b.png"];
rocket[0].scale = (0.4f);
rocket[0].positionType = CCPositionTypeNormalized;
rocket[0].position = ccp(0.5f,0.2f);

rocket[1] = [CCSprite spriteWithImageNamed:@"a.png"];
rocket[1].scale = (.4f);
rocket[1].positionType = CCPositionTypeNormalized;
rocket[1].position = ccp(0.7f,0.2f);

rocket[2] = [CCSprite spriteWithImageNamed:@"g.png"];
rocket[2].scale = (.4f);
rocket[2].positionType = CCPositionTypeNormalized;
rocket[2].position = ccp(0.9f,0.2f);

[self addChild:rocket[0]];
[self addChild:rocket[1]];
[self addChild:rocket[2]];

[self intro];


I'm able to generate one single word, which is fixed, but I don't know to generate a random three letter word every time I start the emulator. Sorry if this is a noobish question. Any suggestions would help!





Aucun commentaire:

Enregistrer un commentaire