Make image clickable and expand

How do I make an image clickable and when I click on it it expands ? Like when you click on your profile picture on Facebook it bloats up big . How can I do that ?

 default = display.newImage( "default.jpg" ) -- position the image default:translate( 160, 75 ) default:scale( 0.1, 0.1 )

That’s my image .

Add a touch handler that adds two transitions on “ended” phase:

--pseudo code for transitions -- Cancel is to stop prior transitions in case of multi-clicks transition.cancel(obj) transition.to( obj, { xScale = 1.5, yScale = 1.5, time = 500, delay = 0 } ) transition.to( obj, { xScale = 1, yScale = 1, time = 500, delay = 500, transition = easing.outBounce } )

play with the timings and scale back transition easing as well as scales.

Umm that’s kind of not what I want . I want the image to have a default size so when the user goes to the profile page, they see their profile picture . So when they click on the picture it expands . 

? That is what the code does.  It expands the object, then goes back to original size.

As soon as I click the profile page the image expands without me clicking it

Yeah, I guess I don’t see the issue.  Just use a transition combined with a touch listener and some custom code to tell the right image to get bigger.

local obj = display.newImageRect( "bob.png", 200, 200 ) obj.touch = function( self, event ) if( event.phase == "ended" and self.xScale == 1) then transition.to( self, { xScale = 2, yScale = 2 } ) end return true end obj:addEventListener("touch")

Ed, I think we’ve done all we can with this one. Absolutely zero willingness to learn, read API docs or even read replies properly. He just wants code he can throw in with no effort or thought on his part. 

Add a touch handler that adds two transitions on “ended” phase:

--pseudo code for transitions -- Cancel is to stop prior transitions in case of multi-clicks transition.cancel(obj) transition.to( obj, { xScale = 1.5, yScale = 1.5, time = 500, delay = 0 } ) transition.to( obj, { xScale = 1, yScale = 1, time = 500, delay = 500, transition = easing.outBounce } )

play with the timings and scale back transition easing as well as scales.

Umm that’s kind of not what I want . I want the image to have a default size so when the user goes to the profile page, they see their profile picture . So when they click on the picture it expands . 

? That is what the code does.  It expands the object, then goes back to original size.

As soon as I click the profile page the image expands without me clicking it

Yeah, I guess I don’t see the issue.  Just use a transition combined with a touch listener and some custom code to tell the right image to get bigger.

local obj = display.newImageRect( "bob.png", 200, 200 ) obj.touch = function( self, event ) if( event.phase == "ended" and self.xScale == 1) then transition.to( self, { xScale = 2, yScale = 2 } ) end return true end obj:addEventListener("touch")

Ed, I think we’ve done all we can with this one. Absolutely zero willingness to learn, read API docs or even read replies properly. He just wants code he can throw in with no effort or thought on his part.