Image select

I would like to select an image

Example I want to select a character of three images.

lets suppose  I choose “image2”

I will use that image in my game.

How can I do that?

[lua]

local image = display.newImageRect( “image.png”, 100, 100 )

image.x = 50

image.y = 100

local image1 = display.newImageRect( “image1.png”, 100, 100 )

image1.x = 50

image1.y = 150

local image2 = display.newImageRect( “image2.png”, 100, 100 )

image2.x = 54

image2.y = 200

[/lua]

Please elaborate on what you mean by ’ select’.  I’m not clear what you are trying to achieve.  Can you please elaborate and give more details?

i  think he means character select, like before a mortal kombat fight you choose your characters (sorry had to have a mk reference). i would do it like this.

-- table to store image files local images = {     "image.png",     "image1.png",     "imag2.png" } -- table to store pickable characters local characters = {} local startY = 100 local function PickMe(event)     -- checcks wether the character is already selected, if so it will do nothing     if event.target.isSelected then         return false     else         --  otherwise it loops over the characters and deselects them all         for i = #characters,1,-1 do             characters[i].isSelected = false         end     -- selects the right character     event.target.isSelected = true end for i = #image,1,-1 do     characters[i] = display.newImageRect(images[i],100,100)     characters.isSelected = false     characters.x = 50     characters.y = startY     -- forget table listeners get straight to the point(or should i say function)     -- excuse the bad joke     characters:addEventListener( "touch", PickMe )     startY = startY + 50 end  

Please elaborate on what you mean by ’ select’.  I’m not clear what you are trying to achieve.  Can you please elaborate and give more details?

i  think he means character select, like before a mortal kombat fight you choose your characters (sorry had to have a mk reference). i would do it like this.

-- table to store image files local images = {     "image.png",     "image1.png",     "imag2.png" } -- table to store pickable characters local characters = {} local startY = 100 local function PickMe(event)     -- checcks wether the character is already selected, if so it will do nothing     if event.target.isSelected then         return false     else         --  otherwise it loops over the characters and deselects them all         for i = #characters,1,-1 do             characters[i].isSelected = false         end     -- selects the right character     event.target.isSelected = true end for i = #image,1,-1 do     characters[i] = display.newImageRect(images[i],100,100)     characters.isSelected = false     characters.x = 50     characters.y = startY     -- forget table listeners get straight to the point(or should i say function)     -- excuse the bad joke     characters:addEventListener( "touch", PickMe )     startY = startY + 50 end