Jump to content
Search Community

roundProps

blase test
Moderator Tag

Recommended Posts

Yep, roundProps can be used to snap x/y coordinates to whole pixels, but you can use it for more than that if you want. It's for any values that should be snapped to whole numbers.

 

TweenMax.to(mc, 2, {x:200, y:100, roundProps:["x", "y"]}); //x and y get rounded every time they're updated

TweenMax.to(customObject, 2, {customProperty:300, roundProps:["customProperty"]}); //customObject.customProperty gets rounded every time it's updated.

Link to comment
Share on other sites

Nope, that's completely different. Your code would just make sure that the END values are rounded downwards, but when you use the roundProps special property, it ensures that at every point during the tween (every time it renders), the values are rounded before being applied to your object. That way, it would always be placed on whole pixels all along the way.

 

Make sense?

Link to comment
Share on other sites

  • 3 years later...
TweenMax.to(container, speed, {bezier:[{y:middle.y},{scaleX:1, scaleY:1,y:middle.y},{scaleX:1, scaleY:1,y:middle.y},{y:end.y,x:end.x, scaleX:.6,scaleY:.6}], startAt:{x:start.x, y:start.y, scaleX:.6,scaleY:.6, alpha:1}, endAt:{scaleX:.2, scaleY:.2, alpha:0}, roundProps:["y", "x"], ease:Sine.easeInOut, repeat:-1, delay:delay});

 

I have this code that I am using I want the X and Y positions to be constrained to int but the scale needs to be a number. This code seems to round all props. Am I doing something wrong?

Link to comment
Share on other sites

Hmm...what's that "endAt" for? That's not a supported special property (unless my memory is failing me) :) 

 

Also, for bezier tweening, every object in the array must contain the same properties. It looks like your first one only has a "y" property but the others have "scaleX" and "scaleY" and one even has "x". 

 

Are you using v12? If so, you can now simplify the roundProps to roundProps:"x,y" instead of roundProps:["x","y"], although the format you used should still work fine. I think the problem is likely in your bezier values and the fact that you don't have consistency. 

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...