Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Callbacks during a tween


andersaloof
 Share

Recommended Posts

Hi,

 

I'm currently making my first game, a math puzzle game in a hexagonal layout, and have a question regarding tweens.

 

I'm trying to flip one of my hexagonal sprites, and it works fine using a tween and setting the scale.y of the sprite to scale.y * -1 as the destination tween value.

 

However, I want to change my sprite texture halfway, giving the illusion of a backside of the tile. Is there a way to get a callback that could do a sprite.loadTexture('backside') when 50% of the tween has played?

 

I've kinda solved it using two tweens, the first tweening scale.y to 0, and the next tweening scale.y to the flipped value, but I would think a callback at x percent of the tweens time/value would be prettier and more manageable.

 

BTW, thanks for a great framework!

So far I'm super impressed and really like the examples and docs, but would be nice if the Classes list would be alphabetically sorted  :)

Link to comment
Share on other sites

I'm afraid there is no way to run a callback mid-way through a tween, so I would go with your current solution of using a chained tween and changing it between one ending and the other starting. If possible try and find a way to do it without using loadTexture too, i.e. maybe putting all the card frames into a texture atlas + the card back, then just changing the sprite frame at the mid-point instead. It will be much cleaner in the long run imho.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...