2 things I'd like to do with cocos2D : 1) set a random board based on 6 png files (like a 6 tiles boardgame) 2) be able to move a sprite/pawn 开发者_StackOverflow社区with my finger and detect on which tile the sprite/pawn was moved and trigger a specific action depending upon which tile is under my sprite/pawn...
any code examples ??? cheers,
Tibi.
one way you could do it would be to create an array of 6 x/y coordinates, one for each of the locations of the tiles. you could use these to move your pawns to and to test if they are in these locations, i.e.
if (pawn.position.x == sotoredLoc.x && pawn.position.y == sotoredLoc.y)
[pawn runAction];
type thing...
for the random part you might want to search for how to create an array of unique random numbers.
精彩评论