problem with displaying image

I have a table of “board” in my game.I can display a square when i have an touch event called but how can I display an image instead?Coz doing so image does appear at the required location .Can anybody suggest me with a solution?I have pointed out the problem area with the comment line…

[lua]module(…, package.seeall)
function new()
local localGroup = display.newGroup()

display.setStatusBar(display.HiddenStatusBar)
local physics = require(“physics”)

board = {}
counter = 1

local img3 = display.newImage(“home.jpg”)
img3.x = 512
img3.y = 384
localGroup:insert(img3)

local img1 = display.newImage(“water01.png”)
img1.x = 500
img1.y = 550
local img2 = display.newImage(“water02.png”)
img2.x = 500
img2.y = 30

setup = function()
counter = 1
board = {}

for i = 1, 10 do
board[i] = {}
for j = 1, 10 do
board[i][j] = {}
board[i][j].square = display.newRect((i-1) * 102, (j-1) * 102, 105, 105)
board[i][j].square:setFillColor(0, 0, 0, 0)

end
end

end
addObstacle = function(event)

if event.phase == “ended” and event.y < 820 then
x = math.ceil(event.x/102)
print(x)
y = math.ceil(event.y/102)
print(y)
board[x][y].isObstacle = 1
if CalcMoves(board, 1, 1, 10, 10) then
–board[x][y].square:setFillColor(100, 0, 0)–This is woking fine

–board[x][y]=display.newImage(“path.png”)–this is not displaying at the specified location.Any alternate solution for doing it??please Help
–board[x][y].x=x
–board[x][y].y=y
end
end
return true
end
Runtime:addEventListener(“touch”, addObstacle)
function CalcMoves(board, startX, startY, targetX, targetY)
local openlist={}
local closedlist={}
local listk=1
local closedk=0
local tempH = math.abs(startX-targetX) + math.abs(startY-targetY)
local tempG = 0
openlist[1] = {x = startX, y = startY, g = 0, h = tempH, f = 0 + tempH ,par = 1}
local xsize = table.getn(board[1])
local ysize = table.getn(board)
local curSquare = {}
local curSquareIndex = 1

while listk > 0 do
local lowestF = openlist[listk].f
curSquareIndex = listk
for k = listk, 1, -1 do
if openlist[k].f < lowestF then
lowestF = openlist[k].f
curSquareIndex = k
end
end

closedk = closedk + 1
table.insert(closedlist,closedk,openlist[curSquareIndex])

curSquare = closedlist[closedk]

local rightOK = true
local leftOK = true
local downOK = true
local upOK = true

if rightOK then
listk=listk+1
tempH=math.abs((curSquare.x+1)-targetX)+math.abs(curSquare.y-targetY)
table.insert(openlist,listk,{x=curSquare.x+1, y=curSquare.y, g=tempG, h=tempH, f=tempG+tempH, par=closedk})
end

if leftOK then
listk=listk+1
tempH=math.abs((curSquare.x-1)-targetX)+math.abs(curSquare.y-targetY)
table.insert(openlist,listk,{x=curSquare.x-1, y=curSquare.y, g=tempG, h=tempH, f=tempG+tempH, par=closedk})
end
if downOK then
listk=listk+1
tempH=math.abs(curSquare.x-targetX)+math.abs((curSquare.y+1)-targetY)
table.insert(openlist,listk,{x=curSquare.x, y=curSquare.y+1, g=tempG, h=tempH, f=tempG+tempH, par=closedk})
end
if upOK then
listk=listk+1
tempH=math.abs(curSquare.x-targetX)+math.abs((curSquare.y-1)-targetY)
table.insert(openlist,listk,{x=curSquare.x, y=curSquare.y-1, g=tempG, h=tempH, f=tempG+tempH, par=closedk})
end

table.remove(openlist,curSquareIndex)
listk=listk-1

if closedlist[closedk].x==targetX and closedlist[closedk].y==targetY then
return closedlist
end
end

return nil
end
setup();

return localGroup

end[/lua] [import]uid: 87661 topic_id: 19130 reply_id: 319130[/import]

Look into setReferencePoint() for your image, see if that helps. [import]uid: 21331 topic_id: 19130 reply_id: 73742[/import]

Disclaimer, i haven’t run your sample code. That said, Tony’s suggestion to use setReferencePoint() sounds like a good one to me. The reason for this is that Corona image display objects draw from their center by default and if you’re anything like me you’re expecting it to be from top left corner. [import]uid: 100558 topic_id: 19130 reply_id: 73753[/import]