Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to Android COCOS2D and developing a simple game to start with. I am developing a game for kids in which the kids shall spell out the names of the fruits they select. I have developed the sprite sheet consisting of pictures of several fruits. Kindly tell me how will the fruit on which the kid taps will get selected. How are the x and y co-ordinates in the sprite sheet determined??

I shall be thankful in case anyone can help me out with this. Thanks in advance

share|improve this question
up vote 1 down vote accepted

Depends on your spritesheet and how you'd like to refer to each sprite.

Horizontal Strip, Evenly Spaced


Coordinates for tile corresponding to position N:

X = N * TileWidth
Y = 0

Grid, Evenly Spaced, Single Index


Coordinates for tile corresponding to position N:

X = (N % Cols) * TileWidth
Y = floor(N / Cols) * TileHeight

In this example Cols equals 3.

Grid, Evenly Spaced, Double Index


Coordinates for tile corresponding to position NX and NY:

X = NX * TileWidth
Y = NY * TileHeight

Irregular Sprite Sheet

Store rectangle regions of each sprite in a seperate file. E.g.

0 0 30 60      // First sprite at (0,0) with size (30,60)
30 0 100 60    // Second sprite at (30,0) with size (100,60)
0 60 130 60    // Third sprite at (0,60) with size (130,60)
share|improve this answer
Please explain the variable "N" denotes what..?? "N" is coordinates of tile or number of tile..?? Thanks – jubin Jan 4 '12 at 16:16
Number of tile, in the order specified on the "diagrams". – David Gouveia Jan 4 '12 at 16:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.