Git Product home page Git Product logo

Comments (2)

rxi avatar rxi commented on August 21, 2024

Just to clarify: each call of :after() creates a new tween which is returned (such that :delay(), :ease() etc. work on the most-recent tween). This means by storing the result of a chain you will get the last tween unless you store the first tween, and then chain onto it. For example:

-- `t` is the last tween in the chain:
local t = flux.to(s, 1, { x = 120, y = 120 }):after(s, 1, { size = 100 })

-- `t` is the first tween in the chain:
local t = flux.to(s, 1, { x = 120, y = 120 })
t:after(s, 1, { size = 100 })

As :after() uses the :oncomplete() function internally, stopping the first tween of the chain will only have an effect if it is the current tween, in which case stopping it will also abort the entire chain, otherwise stopping it will do nothing. This applies to each tween, in that only stopping the current tween will have an effect and stop the chain.

This is the current intended behaviour, and does mean you have to hold onto what the "current" tween in a chain is -- or hold onto them all and call stop them all -- which is somewhat cumbersome. I assume this is the approach you are taking now with :oncomplete()-- keeping hold of a reference to the current tween each time a new one starts?

Depending on your use case it might be easier to create a flux.group() specifically for your chain and simply destroy the group if you want to interrupt the chain -- groups are lightweight so that having many of them is not a problem. I find the approach of each entity and state having its own tween group and having the entity update its own group works well -- it assures an entity's tweens always abide by its timing (pause when it's paused), and that when the entity is killed (stops being updated) all its tweens are effectively killed with it.

from flux.

MitchellTR avatar MitchellTR commented on August 21, 2024

Fair enough. This was mostly an understanding issue and that explanation helps quite a bit. Thanks!

from flux.

Related Issues (7)

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.