Giter Club home page Giter Club logo

Comments (7)

Zinggi avatar Zinggi commented on May 20, 2024

Would it be enough to add a time offset parameter to animatedSpriteWithOptions?
This way you could add an offset to each animation, which should allow you to do what you want, but it might be a bit weird. For instance, if you want to have your animation start at the first frame when inserting a new sprite, you'd have to pass -timePassedSinceStart to timeOffset.

Does the time field in the render config serve another important purpose besides determining a sprites animation frame?

No, currently it's only used in sprite animations

from elm-2d-game.

LegenDAirie avatar LegenDAirie commented on May 20, 2024

Hmmmm my initial reaction to that would be to say no. I am just imaging a scenario where someone might want to have their walking animation speed fluctuate depending on velocity or something.

I guess personally I just found it confusing that time was in render config since the time is really for sprites. As well as not being able to have the control to cancel a running animation half way through the sequence and start a jumping animation at the first frame.

I am very interested in getting on the same page with what you are thinking =). Can you elaborate more on why you would like to keep time in render config? Are you trying to preserve simplicity for those who would like just use a non-reactionary animated sprite? I just wanna make sure I am heading in the right direction

from elm-2d-game.

Zinggi avatar Zinggi commented on May 20, 2024

So The problem with canceling an animation and starting a new one is that it necessarily involves keeping some state (starting time / time already running or similar). This would mean that the library would have to provide it's own update function plus model.

I don't like this, because it makes the library less accessible.
Currently the library only provides view functions. I'd like to keep it this way.

I think advanced users can still do whatever they want using customFragment or veryCustom like this:

veryCustom (\{ camera, screenSize } ->
    renderTransparent vertTexturedRect fragAnimTextured unitSquare
        { transform = makeTransform position rotation size pivot
        , texture = tex
        , bottomLeft = V2.fromTuple bottomLeft
        , topRight = V2.fromTuple topRight
        , duration = duration
        , numberOfFrames = numberOfFrames
        , cameraProj = Camera.view camera screenSize
        , time = yourOwnTime
        }
)

Also, as soon as you want to switch animations, you probably want to introduce some abstract type Animation, that would describe the speed, starting frame, starting time, source rectangle, etc.

This might be a great candidate for a small extension library, but I think it doesn't fit in the scope of elm-2d-game

What about just adding a manuallyManagedAnimatedSpriteWithOptions? E.g. basically the same as AnimatedSpriteWithOptions, but with an additional time parameter that you'd have to manage yourself.
Is that what you had in mind?

from elm-2d-game.

LegenDAirie avatar LegenDAirie commented on May 20, 2024

Yeah, something like that. I think I might have caused some confusing with the term animation. I am referring only to animation frames of a sprite.

Allowing someone to handle all of their own animation states so they can specify exactly what animation frame they are on every tick is what I would like to do.

I completely agree that having the library keep track of animation state is not the right direction and keeping this only for views is.

I like the idea of adding manuallyManagedAnimatedSpriteWithOptions to do that. That way if someone has like a little cloud sprite that just loops and does nothing special, what you already have set up just lets them do that easily otherwise you handle each sprites frame number manually.

Let me know if that makes sense.

from elm-2d-game.

Zinggi avatar Zinggi commented on May 20, 2024

Ok, so I added a manuallyManagedAnimatedSpriteWithOptions. Does this suit your needs?

At some later point I want to rethink the whole animation system and make it more flexible. But for now I think this will suffice.

I wont publish 3.0.0 just yet, as I'll be away for a week, and when I publish a new breaking version I want to be around to fix potential problems.

from elm-2d-game.

LegenDAirie avatar LegenDAirie commented on May 20, 2024

Yes, this is brilliant! I can definitely make due with this!

Thank you!

from elm-2d-game.

Zinggi avatar Zinggi commented on May 20, 2024

The changes are now published 🎉

from elm-2d-game.

Related Issues (6)

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.