Hi. I am creating a widget button that has animation and after it is press it will go to the next scene. I noticed that when I tab the widget button (bye) the defaultFIle = bye.png doesn’t disappear immediately. The widget.newButton-defaultFile and the fuction buttonByePress - this function has the animation sprite- will disappear when the scene fades out to the next scene.
Problem:Is it possible to edit the widget button properties once the widget is created?
How can I make the defaultFile = bye.png disappear once the animation sprite sequence plays the first frame?
Is there a way to make the buttonBye = widget.newButton -defaultFile disappear completely after frame 11 (11 is the first frame) is played?
I uploaded a video of my code test. The bye widget will fade out with the animation sequence.The animation is not that obvious because of the visibility of the defaultFile image.
I also attach my code.
This is the widget Button code.
local buttonBye = widget.newButton { defaultFile ="images/bye.png", emboss = true, onPress = buttonByePress, onRelease = buttonByeRelease, }
The buttonByePress has the animation sequence.
local buttonByePress = function( event ) --show animation when is pressed local buttonBye2 = graphics.newImageSheet( "images/button\_animation\_small.png", { width=108, height=108, numFrames=20, border = 0 } ) -- play 8 frames every 1000 ms --this bye\_Animation object is not local local bye\_Animation = display.newSprite( buttonBye2, { name="cat", start=11, count=20, time=400, loopCount = 1 } ) --properties of the button. The size and the position. bye\_Animation.x = 250; bye\_Animation.y = 400 bye\_Animation:play() screenGroup: insert (bye\_Animation) return true end
Thank you for your time.