Code Monkey home page Code Monkey logo

Comments (11)

Dovyski avatar Dovyski commented on July 22, 2024

That's a nice addition. Any reason to avoid an update() method, @IQAndreas ?

from flixel.

Gama11 avatar Gama11 commented on July 22, 2024

FlxTween? Does flixel-community have tweening?

from flixel.

Dovyski avatar Dovyski commented on July 22, 2024

Yeah, a very simple class was added to handle some dirty work.

from flixel.

Tal3D avatar Tal3D commented on July 22, 2024

To have it work natively with flixel's update loop it might be better to have it extend FlxBasic (just another thought).

from flixel.

IQAndreas avatar IQAndreas commented on July 22, 2024

FlxTween? Does flixel-community have tweening?

#114 (comment)

Any reason to avoid an update() method, @IQAndreas ?

I thought I had a good reason for it. The only thing I remember thinking was that for performance (and synchronization) reasons it may be a bad idea for each instance to have its own "ticker", but we should instead use the "global Flixel time" in some way. If we add it to the list of items that Flixel updates each frame, it would be perfect.

Looking at the way the FlxTween class is currently being used in FlxSound, the progress is updated each frame anyway.

Keep in mind though, you cannot increment with ++ with each call to update, you need (provided it updates each "Flixel Frame"):

public function update():void
{
    this.progress += FlxG.elapsed;
}

I would also recommend adding an autoUpdate flag to the constructor in case users want to manually control the progress based on something other than time. As an example, I considered using FlxTween to control sound panning based on an object's location between the left and right side of the screen.

from flixel.

IQAndreas avatar IQAndreas commented on July 22, 2024

To have it work natively with flixels update loop it might be better to have it extend FlxBasic.

Although, FlxBasic contains many extra properties and values that are unnecessary for just a simple Tween instance.

Also, I would like Tweens to be updated before any classes that use the tween values get their update() method called (perhaps at or before the preUpdate() stage would be best). That way, all places that use the tween get the exact same value each frame.

I don't see a problem in just adding a separate loop in FlxGame that updates all tweens before updating all FlxBasic instances.

from flixel.

Gama11 avatar Gama11 commented on July 22, 2024

In HaxeFlixel, we have a TweenManager plugin that updates all the tweens each frame. I think that's a solid approach, also makes it consistent with the TimerManager.

Tweens themselves are created via static methods like FlxTween.tween() and automatically added to the manager, making them very convenient to use.

from flixel.

IQAndreas avatar IQAndreas commented on July 22, 2024

In HaxeFlixel, we have a TweenManager plugin that updates all the tweens each frame. I think that's a solid approach, also makes it consistent with the TimerManager.

That would work! :) And that way only one item has the overhead of extending FlxBasic, and ticking every frame.

from flixel.

Tal3D avatar Tal3D commented on July 22, 2024

Then we would need a function to add FlxTweens to the manager though.

from flixel.

Dovyski avatar Dovyski commented on July 22, 2024

I think update() and progress can live together. It's up to the developer to decide what to do. E.g. if I just want to "step" the tween and I don't care how it will be done, a call to update() will do the trick. If I want a fine control over the increment, I can manipulate progress directly.

I like the idea of a TweenManager as @Gama11 suggested, but I don't like the idea of tweens being automatically added. IMHO the less automatic things we have, the easier to understand what is going on.

My idea:

// I want total control
var t :FlxTween = new FlxTween();
while(myStuff()) {
  t.update();
}

// or I want Flixel to take care of it for me
FlxG.tweens.add(t);
// later...
FlxG.tweens.remove(t);

from flixel.

Tal3D avatar Tal3D commented on July 22, 2024

While I agree on tweens not being added automatically to the manager I believe they should be removed by the manager automatically once they are finished as it would be redundant to increment the progress over 100% when it will be set back inside the tween to 100% automatically.

from flixel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.