Coordinate system and setPosition

Hey guys,
I’m trying to make a tile map. Basicly, i have lots of images (256 x 256 pix) and i’m trying to align them onto my layer.
The tiles contain tile number (row and column), for example, top left has coords (0,0) and down right has (number of tiles on x axis - 1, number of tiles on y axis -1).
Using these coordinates i’m trying to display the tiles on the layer, and i wrote this function:

Point getOnLayerPosition(int x, int y, int tilenum){ Point ret = Point(128, 128); ret.x += x * 256; ret.y += (tilenum-y-1) * 256; return ret; }

x and y are the row and colum of a tile, and tilenum is the number of tiles displayed on both axis, for example, if tilenum=8, i have 8 tiles in width, and 8 tiles in height, all together, 8*8=64 tiles should be on my layer.

The problem is, when i use this function, it returns the position on layer, not on screen, and when i write something like tile->setPosition(getOnLayerPosition(x,y,tilenum)); it doesnt work like i expect to.
I understand it has to do with some conversion beetwen coordinate systems and/or anchor points, but i can’t get it to work.

Basicly, the question is, how to set a sprite position on layer, when i have its coordinates in layer coordinate system?