[Behavior] LiteTween

  • Words cannot express my gratitude. You made job of so many of us so much easier.

    Thank you kindly. Genui creation.

  • lunarray

    Hey I've got additional question/request if I may

    It would be very helpfull to be able to quickly determine if ANY tweens are currently running in project. Let me give you example why I think its usefull.

    When main menu of game starts, things are tweened in. But if game is resized tweens reset and start again (thats to prevent UI from going bazookas on me because I do my own anchoring to be able to use your wondefull plugin). Player can click "play game" button while it is still tweening. Things will then jump to tween end (so player can skip animations and just start playing sooner) and all user interface will start tweening out. Once it tweens out - game automatically switches layouts.

    So the thing you see is its very nice for me to know if ANY tweens run virtually anywhere in the project.

    Do you have any solutions (I know how to do it with events in construct but it will turn my projects into spaghetti in longer term).

    I would gladly donate you some money as well if you wish through paypal, once my next game sells

  • lunarray

    Thank you very much, this plugin is gold for C2

    I have the following events that works great:

    (player's animation jumps and player's shadow moves on ground in a direct line to the destination point ... the schematic from here)

    But when I tried the same kind of events for another action, I get a strange behavior ...

    (when the player is hit by an enemy, is knocked back with the speed decreasing (using LiteTween) until the speed reaches 0, waits 5 seconds and after that, player's movement returns to normal)

    What am I doing wrong ?

  • I can use this behavior to grid movement?

  • tgeorgemihai

    I'm not sure if I can debug that with just a picture, I probably need a simple capx with that problem to be able to help. However, I tried to make a similar thing using tween position.

    https://dl.dropboxusercontent.com/u/553 ... erHit.capx

    As for your code, I think you forgot to "Set Value" before tweening value. FYI, Set Value set the initial value for value tween while "Set Target" set the target value. If you didn't do that, the initial value will be either zero or the value from the last tween.

    Also, I think you shouldn't use angle+180 to push player, it will produce strange result if the enemy hit a player from behind or when facing left/right. It will only produce correct result if the player is hit from the front.

  • Wenaptic

    Probably yes. I haven't tried it myself, though I think there won't be problem with it.

    PKrawczynski

    That is an interesting problem which I also have encountered along when making UI tweens, can you wait for awhile about it? I need to think over whether or not that feature should be implemented in LiteTween because i don't want it to become bloated. Maybe a storyboard/tweengroup/timeline plugin to control multiple LiteTween? Or should I stay with implementing it in LiteTween, that's a tough decision :3

  • lunarray

    Thank you, I will try to find where my error is. If I can't figure it by myself, I will post the .capx file

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I have been inactive from Construct since last fall.

    Why hasn't a tweening system like this been incorporated into Construct 2 proper yet? Tweening is such an integral part of adding polish to 2D game development.

  • CannedEssence it seems kinda moot since litetween pretty much takes care of it. although I realize it would be nice if it were just in there as part of the established engine. new users don't always know to go to the forums to find a plugin..

    but in the scheme of things.. a solution exists for those who care to search for it. I'm happy to see them adding new things that don't have solutions (like this latest shadow effect) with the time they have.

  • Hi Lunarray,

    Thanks for your wonderful behavior.

    I was interested in the elastic easing function to tweak it a little. After going through the forest of it's code:

        var s=1.70158;var p=0;var a=c;
        if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
        if (a < Math.abs(c)) { a=c; var s=p/4; }
        else var s = p/(2*Math.PI) * Math.asin (c/a);
        return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;[/code:1n2fi5sz]
    
    It turned out it could be simplified as this:
    
    [code:1n2fi5sz]    if (t==0) return b;  if ((t/=d)==1) return b+c;
        return c * Math.pow(2,-10*t) * Math.sin( (t*3-0.25)*2*Math.PI ) + c + b;[/code:1n2fi5sz]
    
    It's also possible to do just this:
    [code:1n2fi5sz]     t /= d;
         return c * Math.pow(2,-10*t) * Math.sin( (t*3-0.25)*2*Math.PI ) + c + b;[/code:1n2fi5sz]
    
    but then it will be a little off at t == d ( around 0.1% )
    
    All these conditions and extra vars are either someone's joke or the result of JS obfuscation/deobfuscation.
  • suntemple

    Ah that one? actually the s and p variable and all can be changed to skew the curve of the elastic behaviour, i'm just making it to 1.70158 to match the default just like the penner's equation (same also with bounce and back). If I removed it all together, I wouldn't be able to use the s and p variable later on if I decided to expose those parameter one day. If you want you could look at the original penner's equation and you'd see that I didn't make any significant change on the original source.

    I can just make it to what you've written to make it much more optimized, but it doesn't make it run any faster during runtime. I used lookup tables, so that calculation would only needed to be done once (precalculation) and it wouldn't ever need to be calculated anymore.

    TL;DR: I'm not trying to make it hard to read or anything about those code sections, I just copied it from the original source . If I changed it to your version, it definitely would run faster, but I am thinking of exposing those variables one day.

  • Okay, makes sense then, thanks for clarification

  • Question: What are the list of attributes for "Initial" - "current" is default. Curious if "fromTo" or other methods like TweenMax/Lite are available.

    EDIT: Nevermind. I switched to LiteTween. Looks like Initial is no longer used.

  • congratulations for this plugin

    There is an error in eventsheet option "Set Target" where "size" in target is missing (there is no souch option)

  • Oh, Size tween actually accepts two parameter which is width and height, you can or should use set target width and set target height for that...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)