Code Monkey home page Code Monkey logo

Comments (5)

 avatar commented on August 23, 2024

is Random() a function of yours, or is this pseudocode? If it's the latter, can you paste something closer to what you're actually using?

I'll take a peek at the source myself, and see if there's anything else I might be able to suggest.

from gokit.

seandanger avatar seandanger commented on August 23, 2024

Pseudocode. In actual use, I'm tweening the value of a health bar for a game. Each time the tween happens, I'm changing the IntTweenProperty's endValue param to the new health value, which could just as easily be a random int between 0 and 100.

from gokit.

 avatar commented on August 23, 2024

Is there a reason why you're not creating a new tween, rather than trying
to edit the property?

  • Michael

On Thu, Jan 28, 2016 at 8:39 AM, seandanger [email protected]
wrote:

Pseudocode. In actual use, I'm tweening the value of a health bar for a
game. Each time the tween happens, I'm changing the IntTweenProperty's
endValue param to the new health value, which could just as easily be a
random int between 0 and 100.


Reply to this email directly or view it on GitHub
#74 (comment).

from gokit.

seandanger avatar seandanger commented on August 23, 2024

I'm aiming to keep the Tween in memory (as a field in this particular class) and reuse it over and over again instead of allocating a new one each time. My original goal was to re-use the property too, but the IntTweenProperty class has no way of changing the target endValue, so I was forced to create a new property to tween with.

As an aside, I've extended IntTweenProperty and added the ability to change the endValue, so I'm not using the above code any longer, but I think the issue still stands that anyone wanting to add properties to an already-run tween will find them non-functional.

Here's that class in case anyone is interested, note that prepareForUse() is called each time the value is changed since GoTween won't call it after the first run.

public class IntAdjustableTweenProperty : IntTweenProperty
{
    public IntAdjustableTweenProperty(string propertyName, int endValue, bool isRelative = false) : base(propertyName, endValue, isRelative)
    {
    }

    public int EndValue
    {
        get { return _originalEndValue; }
        set
        {
            _originalEndValue = value;
            prepareForUse();
        }
    }
}

from gokit.

 avatar commented on August 23, 2024

So I spent a bit more time looking into this, and thinking about it.

Right now we have a smattering of properties that actually have resetWithNewEndValue() that @prime31 put in back in 2013. Perhaps if our AbstractTweenProperty also utilized generics, we could easily add the method to the AbstractTweenProperty class, and be done with it. It'd take a bit of work to do, so I'll leave this ticket open as a potential improvement to attack in the future, or as a challenge for anyone looking to dive in and help out. :)

One more thing to consider, doing something like this doesn't necessarily reset the startValue of the tween, so while doing something like this may allow you to keep a tween in memory and edit the property targets willy-nilly, you're not guaranteed to have a great looking result depending on when you do reset the desired end value to something else.

from gokit.

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.