[Extension] Arcade Easing - Move your sprite from A to B in style!

I love seeing my first-ever extension getting used in so many different projects. Gorgeous work, Chimbro!

10 Likes

I honestly find image transformations really hard NOT to use, it’s so useful!

6 Likes

Ehe… how would you even go about that?

4 Likes

This is pretty nice. How can we direct where the sprite goes?

1 Like

Depends whatcha mean, for the first block you just put in the x and y for where you want it to ease and it just… eases.

2 Likes

Okay, I know I am about a year late, but could I get an update that allows for easing just a number variable? It would be a small change, but immensely useful.

1 Like

Yeah sure! Ill get to it

1 Like

I’m still trying at it but I’m getting unsure if this is actually possible… I don’t know if it’s actually doable to keep returning values from a singular number block, I’m still more noob than pro but still… sorry to ping this is so stupid but @richard does this sound possible?

1 Like

I removed the ping to Richard because he’s not the only one who can help you on this. :smiley: Describe in more detail how you’re thinking about implementing this, Chimbro. I can think of a few ways where you might be able to do this.

1 Like

Oh hey AlexK! Ok here goes… I’m not that good at extension stuff so I may get some wording wrong, but…

For the actual part of the extension that implements the easing, it’s all in one giant class function (called THE JOB SYSTEM, might be better than the one in my country), which has a switch case in the update section for when the user puts in what type of thing they want to ease. I tried adding another type for the number idea, by adding another property and subbing all the easing stuff into that, then returning it in the number block.

And once it wasn’t working (I mean, nothing ever works first try but hehe I mean anyhow) I started questioning the fact that the function I’m easing isn’t actually in the update section of my easing implementer, so how would it be possible to return every value in the ease, one at a time, and not just the first one? This is kinda where I got stuck and finally gave in to my major coding skill issue and never showed my face to society ever again

Anyway…

This is the part that I stopped at:

I’m interested as to how you think it’s possible, I’ve thought about it for a bit and see basically no way around it :thinking:. Like how can you make a function return a value into a variable over and over and over? It just felt like an unsaid rule of thumb that it isn’t possible and only functionally makes sense in a class function.

1 Like

You definitely have the right idea, Chimbro! And I think you have all of the pieces of the puzzle. Still, this is a tough one.

You have an update() function that is called automatically by your extension. I assume somewhere in your extension, you call that in a game.onUpdate() call.

You could implement a similar function for numbers, but then return the current value, as a function cannot manipulate a variable and have it persist outside of the function. So, you’d have something like this in your extension:

updateNumber(): number {
    // Start with this, since you're missing the `now` parameter.
    // You'll need to keep track of the `startTime`s for each job ID.
    now: number = game.runtime() - startTime
    // Do your magic here.
    // Remember to return the updated value.
    return newValue
}

Then, you’d need the user to both initiate the easing function as usual, but then also update the variable in a game.onUpdate() call.

// Somewhere in `main()`
// easeNum() will need to return the job ID.
let myEasedVariable: number
let myJobId: number = easeNum(0, 10, 1000, `pick a mode`)

game.onUpdate(() => myEasedVariable = updateNum(myJobId))

It’s not as clean as easing a sprite, since a sprite can retain state information, whereas a number variable cannot.

Your other option is to create a custom type. Cleaner for the user, but they’ll need to use your custom type and not a simple numeric variable.

Just some ideas. Happy to explain anything in more detail.

3 Likes

Ahhhhhhh… I seeeeeeeeee…

Okay! That makes sense, I think I was a bit too tunnel visioned on it being one pure, perfect block, mainly because I already have the generic easing function block, but I mean, sure, glad to know it’s possible at the very least! I’ll see what I can doooooo… this might use up a bit of brain juice stuff…

2 Likes