[SOLVED] Changing different images when tweeing/moving

Would appreciate if anyone can point me in the right direction. Thanks in advance.

I place an object on the right of the screen. When I touch it, it will go to the left. Touching it again, it moves to the right.

local function moveImage(event)  
 local bubble = event.target  
 if (event.phase == "ended") then  
 if whichway == "left" then  
 local tween = transition.to(bubble, {time=1000, x=150, y=800})  
 else  
 local tween = transition.to(bubble, {time=1000, x=650, y=800})  
 end  
 if whichway == "left" then  
 whichway = "right"  
 else  
 whichway = "left"  
 end  
 end   
end  
  
local function addImage()  
 bubble = display.newImage("mouse-L.png")  
 bubble.x = 650 bubble.y = 800  
 localGroup:insert(bubble)  
-- move image if touched  
 bubble:addEventListener("touch", moveImage)  
end  

Now this works fine for an image like a square or a circle. I want to have a mouse (or any animal image) that will face left when it moves left and will turn around facing right when it moves to the right. So I 2 images, mouse-L.png facing left, and mouse-R.png facing right.

How can I swap the images? or is it possible? Am I approaching this the right way?

As I understand it, the event-listener is attached to the first image, if I swap another image, touching the new image doesn’t do anything. [import]uid: 108015 topic_id: 23714 reply_id: 323714[/import]

If you use 1 image and use xScale = -1 it will flip the image :slight_smile: [import]uid: 10389 topic_id: 23714 reply_id: 95341[/import]

Oh man, so simple! works great. Many thanks. [import]uid: 108015 topic_id: 23714 reply_id: 95344[/import]