I’m new in the Lua and Codea, and I wanna ask if there is a way to interact with the pics. Such as -
if pic == touched then
x = 90
I need to know what the “if pic == touched then” part should be.
@JustPlaying You need to know the edge x,y values of the picture. The x,y edge values will vary based on the size of the picture and where on the screen you place it. Then it’s just a matter of where you touch.
if touch.x > left_edge and touch.x < right_edge and touch.y > bottom_edge and touch.y < top_edge then do something.
@JustPlaying Here’s an example using a sprite. The sprite is 110x110 pixels in size which is why I add and subtract 55 ( 110 / 2 ) to get the edge values from where the sprite is displayed. Just touch the sprite or slide your finger across it.
background(40, 40, 50)
if hit then
if t.state==BEGAN or t.state==MOVING then
if t.x>WIDTH/2-55 and t.x<WIDTH/2+55 and
t.y>HEIGHT/2-55 and t.y<HEIGHT/2+55 then
if t.state==ENDED then