Jump to content

Tween atlas frame on iPad


Anderberg
 Share

Recommended Posts

I am having trouble when tweening the frame of an atlas sprite. The issue appears on the iPad, but not on the computer.

 

I am using GSAP's TweenMax and here is parts of the code:

new TweenMax(this.rightWing, 5, {  frame: this.rightWing.frame + 4,  ease: SteppedEase.config(4)})

This should tween the rightWing over 5 seconds and change frame from 1 to 5, in 4 steps.

 

It works perfectly on all of my browsers on my computer, but not on the iPad, it only shows the first frame. I have debugged it and the frame does change, but the graphics do not update.

 

Have anyone encountered a similar issue?

 

Link to comment
Share on other sites

Does it work when setting the render mode to Phaser.CANVAS on your desktop browsers?

 

Also, in TweenMax you have roundProps too, I don't know if that will fix it but I suspect for this you'd be better off using that since you're just wanting integers, rather than specifically defined steps:

new TweenMax(this.rightWing, 5, {  frame: this.rightWing.frame + 4,  roundProps: ['frame']})
Link to comment
Share on other sites

It does not work when using Phaser.CANVAS. Do you know why that is?

 

I realized that I have another animation that uses the same atlas and that one works:

TweenMax.to(this.beak, 0.2, {  frame: this.beak.frame+1,  roundProps: 'frame',  ease: Power0.easeInOut,  repeat: -1,  yoyo: true});

(Also, thanks for pointing out the roundProps!)

Link to comment
Share on other sites

I've been doing a lot of digging and it seems that the issue is that I tint the sprite. Without tinting it the frame graphics will update accordingly.

 

Does that spark any idea of where the problem might lie?

 

Edit:
I added a minimal tint change when updating the frame, it now seems to work. However it is of course not optimal to do unnecessary tints.

 

In other words: Changing frame when in CANVAS mode works when...

... no tint has been applied.

... you change the frame and the tint.

Link to comment
Share on other sites

  • 5 months later...

Hi guys!  :D

 

Look at this answer: http://greensock.com/forums/topic/11177-animate-phaser-sprite-with-tweenmax-frame-by-frame/

var frames = this.player.animations.frameData.getFrames();TweenMax.to(this.player, 2, {  frame: frames[frames.length - 1].index,  roundProps: 'frame',  ease: Linear.easeNone,  repeat: -1,  yoyo: true});   

Regards, Nicholls

Link to comment
Share on other sites

Hi Nicholls!

Great that you took another look at it! I haven't been able to try your solution since my code has changed so much since this issue was reported.

The tinting-then-changing-frame issue is still a problem in Phaser (Canvas only), so I am not quite positive that your solution actually fixes that. Is your sprite tinted? Are you able to change frame without re-tinting it?

Link to comment
Share on other sites

I took the liberty of changing your pen to expose the error: http://codepen.io/AnderbergE/pen/ByZBLy

 

I've changed:

* Game runs on CANVAS, not AUTO. The bug is not shown when you use webGL.

* Added a tint to the ninja.

 

(I also found that I created a codepen with the issue before: http://codepen.io/AnderbergE/pen/GpiAe)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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