Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new blocks to tweening extension #727

Closed
wants to merge 4 commits into from

Conversation

notunk0wn23
Copy link

This adds 3 new blocks that all allow you to run an eased animation in one block rather that having to make a script yourself. There are 3 new blocks:

(linear v) ease (in v) from x: (-100) y: (-100) to x: (100) y:(100) at speed (1) :: extension

(linear v) ease (in v) to x: (100) y:(100) at speed (1) :: extension

(linear v) ease (in v) from size: (0)% to size: (100)% at speed (1) :: extension

Yes, that is in scratchblocks.
https://scratchblocks.github.io/#?style=scratch3&script=(linear%20v)%20ease%20(in%20v)%20from%20x%3A%20(-100)%20y%3A%20(-100)%20to%20x%3A%20(100)%20y%3A(100)%20at%20speed%20(1)%20%3A%3A%20extension%0A%0A(linear%20v)%20ease%20(in%20v)%20to%20x%3A%20(100)%20y%3A(100)%20at%20speed%20(1)%20%3A%3A%20extension%0A%0A(linear%20v)%20ease%20(in%20v)%20from%20size%3A%20(0)%25%20to%20size%3A%20(100)%25%20at%20speed%20(1)%20%3A%3A%20extension

image

@LilyMakesThings
Copy link
Contributor

Woohoo!

const progress = Cast.toNumber(Math.round(this.clamp(util.stackFrame.loopCounter, 0, 100))) / 100;
const tweened = this[easeMethod](progress, easeDirection);
const x = Cast.toNumber(this.multiplierToNormalNumber(tweened, endx, startx));
const y = Cast.toNumber(this.multiplierToNormalNumber(tweened, endx, startx));
Copy link
Collaborator

@DNin01 DNin01 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

References to endx and startx on the right-hand side of const y = ... should be changed to endy and starty. Otherwise, the y position will be the same as the x position. There are 2 occurrences of this issue.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

References to endx and startx on the right-hand side of const y = ... should be changed to endy and starty. Otherwise, the y position will be the same as the x position. There are 2 occurrences of this issue.

Ah. Not sure how I didn’t catch that, I tested all of my blocks and they work fine.
As for the workflows, I’ll try to reverse that. I originally tried to add a action myself, and later realized that I didn’t want or need to use GitHub.io, just a local server, not knowing there was already workflows inside.

@@ -81,224 +128,295 @@
const tweened = this[easeMethod](progress, easeDirection);
return this.multiplierToNormalNumber(tweened, start, end);
}
tweenPlayAnimationPosition(args, util) {
Copy link
Collaborator

@DNin01 DNin01 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, the sprite doesn't glide from point A to point B properly when using this block. Try it for yourself - setting mode to "linear", it should glide to the ending point at a fixed rate, but it instead eases in and eases out, and seems to stop before the block finishes.

This is probably because some starting position constant is constantly getting updated with the sprite's current x position whenever it moves forward a step, but it should stay the same throughout the whole animation. Haven't studied where that happens, though.

This does not happen with any of the other blocks.

If you don't want to diagnose this, you can probably get away with removing this block as it's as easy as inserting the reporters x position and y position into the block after this one to achieve basically the same behavior.

Copy link
Collaborator

@DNin01 DNin01 Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't remove workflow files from this pull request, or they will get removed from the upstream repository when the PR is merged. Instead, you can disable Actions on your fork from Settings → Actions → General.

Tip: It's possible to revert commits in Git as well as GitHub Desktop.

@GarboMuffin
Copy link
Member

Ignore the current "All checks have failed" -- that's unrelated

Would it make sense to replace the idea of "speed" with just the total time of the tween instead?

@notunk0wn23
Copy link
Author

Ignore the current "All checks have failed" -- that's unrelated

Would it make sense to replace the idea of "speed" with just the total time of the tween instead?

Probably. Ill try that.

@GarboMuffin
Copy link
Member

It looks like someone else has opened something similar #766

@JeremyGamer13
Copy link
Contributor

could these use seconds instead of the vague "speed" number?
it also feels like the first block should just act like the second block but with the first numbers being the current sprite position

@notunk0wn23 notunk0wn23 marked this pull request as draft July 22, 2023 20:34
@notunk0wn23
Copy link
Author

ok i've been neglecting this entire pr for a while now so im gonna draft it for now until i feel like working on it

GarboMuffin added a commit that referenced this pull request Aug 8, 2023
GarboMuffin added a commit that referenced this pull request Aug 8, 2023
@GarboMuffin
Copy link
Member

Superceded by #851

@GarboMuffin GarboMuffin closed this Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants