Button change and animation Help

So what im trying to achieve is this
when i touch a Button the height and width shrink about 5 pixels in both height and width then after say .5 seconds it goes back to normal size then changes image.
so say its a sound on sound off button,when touched changes to sound off touched again back to sound on,with that little animation,kind of like squashing a balloon effect

thanks [import]uid: 65492 topic_id: 19934 reply_id: 319934[/import]

its a rough code, but you can do something like this
its probably better to just use sprites for this occasion
[lua]local btn = display.newImage(“btn.png”)
btn.isHitTestable = true
btn.x = 150
btn.y = 150

local btn2 = display.newImage(“btn2.png”)
btn2.x = 150
btn2.y = 150
btn2.isVisible = false
local function onTouch(event)
if event.phase == “ended” then
if btn.isVisible then
btn.xScale = btn.xScale + 1
btn.yScale = btn.yScale + 1
end
if btn2.isVisible then
btn2.xScale = btn2.xScale + 1
btn2.yScale = btn2.yScale + 1
end
local function to_normal()
btn.xScale = 1
btn.yScale = 1
btn2.xScale = 1
btn2.yScale = 1

btn.isVisible = not btn.isVisible
btn2.isVisible = not btn2.isVisible

end

timer.performWithDelay(1000, to_normal,1)
end
end

btn:addEventListener(“touch” , onTouch)[/lua] [import]uid: 16142 topic_id: 19934 reply_id: 77557[/import]

this increases the size of the object not shrinks it,but thanks anyway [import]uid: 65492 topic_id: 19934 reply_id: 77592[/import]

its resize on touch and then get back to normal and changes picture on complete
maybe you lack a .png images and code is not working properly for ya [import]uid: 16142 topic_id: 19934 reply_id: 77596[/import]

no the images change perfect but the animation was meant to shrink in size, not bulge out where you have the scale of x and y is +1 which makes it bigger, btn.xScale doesnt allow for negative numbers so i cant make the image go smaller before returning to its original size. [import]uid: 65492 topic_id: 19934 reply_id: 77601[/import]

you can write “btn.xScale = btn.xScale - 1”… [import]uid: 16142 topic_id: 19934 reply_id: 77607[/import]

doesnt scale down already tried that one [import]uid: 65492 topic_id: 19934 reply_id: 77629[/import]

sorted it

local _H = display.contentHeight;
local _W = display.contentWidth;
local btn = display.newImage(“btn.png”)

btn.isHitTestable = true
btn.x = 150
btn.y = 150

local btn2 = display.newImage(“btn.png”)
btn2.x = 150
btn2.y = 150
btn2.isVisible = false

local function onTouch(event)
if event.phase == “ended” then
if btn.isVisible then
btn.xScale = btn.xScale - .2
btn.yScale = btn.yScale - .2
end
if btn2.isVisible then
btn2.xScale = btn2.xScale - .2
btn2.yScale = btn2.yScale - .2
end
local function to_normal()
btn.xScale = 1
btn.yScale = 1
btn2.xScale = 1
btn2.yScale = 1

btn.isVisible = not btn.isVisible
btn2.isVisible = not btn2.isVisible

end

timer.performWithDelay(200, to_normal, 1 )
end
end

btn:addEventListener(“touch” , onTouch ) [import]uid: 65492 topic_id: 19934 reply_id: 77631[/import]