Jump to content
Search Community

TweenMax - for a ballgame?? crazy or cool? [SOLVED]

CleverAndClown test
Moderator Tag

Recommended Posts

hello .

 

I am fiddling around with the great TweenMax. I 've been using it a lot for simple animation, ads etc.

 

Now I have this idea to triy and set up a ball game (like tennis) using the bezier.

 

. prob 1. How do I write a bezier curve with sharp corner, so the ball bounces like a tennisball would. Now I am trying to set up tween after tween and calculate the progress, but something says that i might be done easier, more effective if I give it a list.

 

- prob 2. I want to use the dropshadow while using the bezier (to give the shadoweffect to make the ball seem to go up). Having this idea that if I could listen for the progress of the tween and animate the shadow distance/angle according to progress. But again, I have this feeling that this supersmart toy you have made might hide a easier way, like "animate from A to B to A".

 

And how do I set up a function that listens for the progress - I just don't get the docs?

 

Do you get it. Perhpas It is totally ff the path to use TweenMax for animation gamegraphic but I find the performance of the code very efficient (and better than my own physic's code -:)

 

by the way GREAT work -

Link to comment
Share on other sites

Well, making a bezier have sharp corners is...well...it's not made for that kind of thing. Sorry. But you could string several bezier tweens together and that'd create sharp edges between. Check out the new TimelineLite and TimelineMax classes - they make it simple to string tweens together and control them as a whole.

 

You also might want to use physics instead of a bezier. Imagine setting an object in motion with a certain velocity but have it accelerate in a different direction (like down for gravity) - you'd get a curved motion that way. It seems particularly well-suited for a ball game. :)

 

Check out the physics2D example in the Plugin Explorer.

 

If you want to get the progress each time a tween is updated, just use an onUpdate for that - it'll call any function you want each time the values are updated. And you can watch the currentTime or the ratio property depending on the effect you're after.

 

Hope that helps.

Link to comment
Share on other sites

ok - we are all so ungreatful. Yu are giving us this magic tao and all we say is "can we make the elephant fly as well?" :lol:

 

I'll go on and try my experiment. I wanna work in a cartoon style so I think bezier will give the look I want. Real Physics can be so booring to look at sometimes (And by the way Inever would have discover the scrollbar on the explorer if you haven't mentioned it :()

***

 

but I dont get the syntax for setDestination:

setDestination for "x" - fine that works

 

but how do I setDestination for "distance" using the dropShadow, I get no reaction. My idea is to alter the distance on every _onUpdate.

 

TM = TweenMax.to(tBall, 5, {onUpdate:_onUpdate, ease:Sine.easeInOut, bezier:[{x:200, y:100}, {x:200, y:200},{x:300, y:200}, {x:300, y:300}], scaleX:1.1, scaleY:1.1, orientToBezier:true, dropShadowFilter:{color:0x000000, alpha:0.5, blurX:0, blurY:0, strength:2, distance:30}});

 

 

private function _onUpdate() {

TM.setDestination("x", tBall.x +=10)

TM.setDestination("distance", 500)

}

 

/ L

Link to comment
Share on other sites

Unfortunately, the live updating isn't something that plugins can handle seamlessly. You can still do it like this: myTween.setDestination("dropShadowFilter", {distance:10, color:0xFF0000}); and it will indeed go to that new value, but it may not look seamless at the moment you call setDestination(), and you'll need to make sure that you pass all the destination values, not just the one you're trying to update. It's a lot more complex than you might expect to handle something like this. I'll try to look into this further at some point to see if I can figure out an elegant way to handle things without adding a lot of kb or slowing things down.

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