know when a spawned object is in a certain position

Hey guys so my game is a stacking game where you have to get to a certain height with the blocks but how would I figure out when the final block is at the certain height??

local physics = require("physics") physics.start() -- blocks u get to use below local numberofblocksallowed = 9 local checkpointreached = false local bg = display.newImage("bg.png",160,240) bg:scale(5,9) local ground = display.newRect(180,500,360,50) physics.addBody(ground,"static") local function spawnBear (event) if(numberofblocksallowed \>=1) then local bear = display.newImage("bear.png",event.x,50) physics.addBody(bear,"dynamic") numberofblocksallowed = numberofblocksallowed-1 print(numberofblocksallowed) end end Runtime:addEventListener("tap",spawnBear) local stackline = display.newRect(230,0,600,10) local function finalblock (event) if (numberofblocksallowed ==0) then --would I put code in here end end

When it stops moving, i.e. a collision with the object below it, you can get the object’s .x and .y in the collision handler. You can then test to see if the .y is less than some value which is the value you deem to be stacked too high. 

Rob

When it stops moving, i.e. a collision with the object below it, you can get the object’s .x and .y in the collision handler. You can then test to see if the .y is less than some value which is the value you deem to be stacked too high. 

Rob