Something wrong

I have coded this app but i don’t understand why it doesn’t work

local option = { width = 104, height = 67, numFrames = 7, } local sheet = graphics.newImageSheet( "nuota.png", option) local animazione = {name = "swim" , start = 1 , count= 7, time = 300, loopCount = 0} local swim = display.newSprite( sheet , animazione) swim.x = 128 swim.y= 119 function muoviti() transition.to(swim, {time = math.random(45000 , 50000) , x = 984 }) end muoviti() function loose() if swim.x == 300 then print("you loose") end end loose()

But when the swim.x is 300 the simulator doesn’t show me " you loose"

the function loose() is not a Runtime listener, which is, I assume, what you’re looking to implement. At this point, your loose() function is just running once and isn’t running continually in order to identify if your swim.x coordinate is at 300.

Can you make an example to solve it?? Please I’m a newbie

The best place for new users to start is with the documentation. Here is the documentation explaining the Event listener system and how best to work within it regarding Corona SDK.

http://docs.coronalabs.com/guide/events/detectEvents/index.html

Even with a runtime listener, if you are using transition.to() call to move the object you might not trigger the swim.x == 300 part of your code. In one frame the x pos might be 299 and the next it might be 301.

the function loose() is not a Runtime listener, which is, I assume, what you’re looking to implement. At this point, your loose() function is just running once and isn’t running continually in order to identify if your swim.x coordinate is at 300.

Can you make an example to solve it?? Please I’m a newbie

The best place for new users to start is with the documentation. Here is the documentation explaining the Event listener system and how best to work within it regarding Corona SDK.

http://docs.coronalabs.com/guide/events/detectEvents/index.html

Even with a runtime listener, if you are using transition.to() call to move the object you might not trigger the swim.x == 300 part of your code. In one frame the x pos might be 299 and the next it might be 301.