Jump to content
Search Community

Problem with physicsProps and transformAroundCenter

stenrap test
Moderator Tag

Recommended Posts

Hi all,

 

When I simultaneously tween with physicsProps and transformAroundCenter in a timeline, the latter seems to override the former (the physicsProps tween simply stops). Following is a snippet of the code in question:

 

setupTimeline.append(TweenMax.to(step10Bitmap, 0.72, {alpha:1.0, physicsProps:{x:{velocity:-552, acceleration:410}, y:{velocity:253, acceleration:460}}}), -0.15);
setupTimeline.append(TweenMax.to(step10Bitmap, 0.72, {transformAroundCenter:{rotation:360}}), -0.72);

 

I tried adding "overwrite:0" to the vars object of the first tween, but that doesn't make any difference. I also tried setting a higher value for the offset of the second tween so they wouldn't execute at exactly the same time, but the second tween still kills the first tween (it just takes a little longer). I'm just trying to cause an object to spin and fall at the same time, so I have two questions:

 

1. What's wrong the way I'm trying to do it above?

2. Is there some other/better way to accomplish a simultaneous spin/fall?

Link to comment
Share on other sites

When you transformAroundCenter, you actually change the x/y values too (unless the registration point is centered, but if it were, there would be no purpose for using transformAroundCenter in the first place). Imagine a big 500x500 box with its registration point in the upper left corner (0, 0). If you transformAroundCenter and scale it to 0.5, imagine watching that upper left corner registration point as the tween proceeds - it would move down and to the left, ending at 125, 125 even though you didn't specifically tell transformAroundCenter to edit the x/y values. Likewise, if you rotate the object around its center, x and y get affected as well. In our example, rotating 90 degrees would make the x/y go from 0/0 to 500,0.

 

So the point is that you can't really use transformAroundCenter and also do another tween that affects x/y (in this case, physicsProps) as well and expect them not to affect each other.

 

Can you just make your registration point in the center to begin with? That way you can just do a regular rotation tween and use physicsProps on the x/y (in fact, you might want to use physics2D because it's faster & probably a bit easier). If you can't control the registration point in the raw asset, you could consider nesting it inside another Sprite and offset its x/y so that the Sprite's registration point ends up being centered on the object and then just tween that container Sprite.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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