swapping image

Is there a way to swap an image on touch? [import]uid: 99780 topic_id: 16940 reply_id: 316940[/import]

@ coolrasi

There`s couple of ways actually but it also depends how many images ?
For example if all your images are inside a table and you just want to
swap to another image inside a table every time you touch image or if
you have 2 images and every time you touch the image the 2nd one
appears then if you touch picture #2 the #1 appears and so on so on.

Assuming you have 2 pictures you can easily do this by making one
invisible using .isVisible = false when you touch it [import]uid: 30314 topic_id: 16940 reply_id: 63518[/import]

if the images are related and the same size, then use the sprites, you need to just change the frame number and you are done.

However for different sized images, you will have to employ either one of the methods

  1. have variables of every image so you can reference them and switch them on/off based on which one is touched
  2. Have a table as suggested above
  3. use something like thisImg:removeSelf() and then thisImg = display.newImage(“newImage.png”) and then position it where the last image was.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 16940 reply_id: 63530[/import]

Basically what I am asking is this…Say for example I have 5 images in my table and now I want to swap any two image. what i do is i touch any one image and then when i touch the 2nd image both the 1st and the 2nd image interchange their position.Now can you tell me how to do that? [import]uid: 99780 topic_id: 16940 reply_id: 63616[/import]