I guess I don’t understand “onComplete” in the GTween function.
Here is what I want to do: My splashScene has a start button to take the player to the game. It works fine. But I’ve added an image as bitmap with alpha=0 that I want to fade in BEFORE the scene changes to the playScene.
Here is what I did (the code is below):
1. The event listener for the button calls the “onClick” function.
2. The “onClick” function calls the GTween function to increase the alpha to 1 over 5 seconds.
3. The GTween function has an “onComplete” argument to call startButton:goToPlay(), which changes the scene.
What actually happens: When I click the start button, the scene changes without the image fading in.
Testing (various changes to the “onClick” function and the results:
1. If I just add a call to startButton:goToPlay(), without GTween, clicking the button takes me to the play scene as expected.
2. If I just add the GTween function with only increasing alpha to 1 over 5 seconds WITHOUT the call to startButton:goToPlay(), clicking the button results in the image fading in and nothing else, as expected.
3. And as I said before, with the GTween set to do the fade in and the call to startButton:goToPlay(), it doesn’t show the fade in and just goes straight to the play scene.
So how can I get this to do the fade in and THEN go to the play scene?
function startButton:goToPlay()
print("going to play")
sceneManager:changeScene("play", conf.transitionTime, conf.transition, conf.easing)
end
function startButton:onClick()
print("start button function started")
GTween.new(goodLuck, 5, {alpha=1, onComplete=startButton:goToPlay()})
end
startButton:addEventListener("click", startButton.onClick) |
Comments
I think it should be done so
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
First, if you don't use GTween, how would you create this behavior (fade an image before changing scenes) or haven't you done this (or wouldn't do it)?
I'm not sure how to implement what you suggested, but I tried changing the code of the "onClick" function to the code below. But with this code, I get the fading, but it doesn't switch the scenes. Based on the output of print statement the "onClick" function is called, but the "startButton:goToPlay()" is NOT called.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
As you can see from my post before this one, I figured out that I needed the dispatchEvents, but your way of adding it is simpler than the way I did it and I prefer your way.
Thanks again.
Any idea why your way didn't work, but mine did. I'd prefer to not use making those animate and properties tables if it's not necessary.
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I do not understand what you are.
Give me a short example of using GTween and textureregions
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
https://deluxepixel.com
Keszegh, I tried your edited code and it works fine. Thanks.
Regarding the discussion of MovieClip, I'll try that in a future project, but for completing this one, I'll stick with gtween since I've got it working.
Likes: antix