Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Need help with this engine:
- ivandur112
-
Scratcher
40 posts
Need help with this engine:
How animate Sonic here?:
https://scratch.mit.edu/projects/1257954364
https://scratch.mit.edu/projects/1257954364
- Scratch-Minion
-
Scratcher
1000+ posts
Need help with this engine:
Make 4 consecutive costumes R-Run1, R-Run2, R-Run3, R-Run4.
Also make 4 consecutive costumes L-Run1, L-Run2, L-Run3, L-Run4 by reflecting the costumes in the editor.
Then the code below will cycle through the costumes.
(It replaces your current code for Run at the end of your My Block “paint sprite”.
Also make 4 consecutive costumes L-Run1, L-Run2, L-Run3, L-Run4 by reflecting the costumes in the editor.
Then the code below will cycle through the costumes.
(It replaces your current code for Run at the end of your My Block “paint sprite”.
if <<(action) = [Run]> and <(direction) = [R]>> then
if <<(costume [name v]) = [R-Run1]> or <<(costume [name v]) = [R-Run2]> or <(costume [name v]) = [R-Run3]>>> then
next costume
else
switch costume to [R-Run1 v]
end
end
if <<(action) = [Run]> and <(direction) = [L]>> then
if <<(costume [name v]) = [L-Run1]> or <<(costume [name v]) = [L-Run2]> or <(costume [name v]) = [L-Run3]>>> then
next costume
else
switch costume to [L-Run1 v]
end
end
- g6g6g66g6g
-
Scratcher
72 posts
Need help with this engine:
It's preferable not to check for the current costume, especially when they all end with a convenient number. To run through each costume in a run cycle, you can do
Of course this isn't all, this goes in with the rest of the script that decides what actions are taken. If you want the animation to speed up as the player runs faster, decide the frame based on the amount of distance the player has traveled e.g. next costume every 18 units of distance.
DEMO
when I receive [tick v]
set [runframe v] to (((runframe) mod (number of frames)) + (1))
switch costume to (join [Run] (runframe))
Of course this isn't all, this goes in with the rest of the script that decides what actions are taken. If you want the animation to speed up as the player runs faster, decide the frame based on the amount of distance the player has traveled e.g. next costume every 18 units of distance.
change [runframe v] by ([abs v] of (xvel)::operators)
switch costume to (join [Run] ((([floor v] of ((runframe) / (dist before next frame))::operators) mod (number of frames)) + (1)))
DEMO
- ivandur112
-
Scratcher
40 posts
Need help with this engine:
Make 4 consecutive costumes R-Run1, R-Run2, R-Run3, R-Run4.
Also make 4 consecutive costumes L-Run1, L-Run2, L-Run3, L-Run4 by reflecting the costumes in the editor.
Then the code below will cycle through the costumes.
(It replaces your current code for Run at the end of your My Block “paint sprite”.if <<(action) = [Run]> and <(direction) = [R]>> then
if <<(costume [name v]) = [R-Run1]> or <<(costume [name v]) = [R-Run2]> or <(costume [name v]) = [R-Run3]>>> then
next costume
else
switch costume to [R-Run1 v]
end
end
if <<(action) = [Run]> and <(direction) = [L]>> then
if <<(costume [name v]) = [L-Run1]> or <<(costume [name v]) = [L-Run2]> or <(costume [name v]) = [L-Run3]>>> then
next costume
else
switch costume to [L-Run1 v]
end
end
1. OMG, it's that really you @Scratch-Minion!?!?!?!?
Cool!2. Thanks!
- ivandur112
-
Scratcher
40 posts
Need help with this engine:
SONIC MYSTIC ENGINE 0.0.2 JUSTT RELEASED!!! |||||
VV
https://scratch.mit.edu/projects/1258026619/
Now, what you purpose for 0.0.3?
PLANNED FOR FUTURE
-Add sounds
-Add a proper spin
-Add spindash
VV
https://scratch.mit.edu/projects/1258026619/
Now, what you purpose for 0.0.3?
PLANNED FOR FUTURE
-Add sounds
-Add a proper spin
-Add spindash
- Scratch-Minion
-
Scratcher
1000+ posts
Need help with this engine:
Hi again.
Just a note that I thought you would use the four existing costumes Run1, Run2, Run3, Run4 in the sprite for the right running Sonic costumes.
Just a note that I thought you would use the four existing costumes Run1, Run2, Run3, Run4 in the sprite for the right running Sonic costumes.
- ivandur112
-
Scratcher
40 posts
Need help with this engine:
Hi again.
Just a note that I thought you would use the four existing costumes Run1, Run2, Run3, Run4 in the sprite for the right running Sonic costumes.
There's only 4 anims used for each direction: for left: L-Run1 and L-Run2; and for right: R-Run1 and R-Run2
- ivandur112
-
Scratcher
40 posts
Need help with this engine:
Hi,
Anyone knows how can I have the solution to this issue in 0.0.4?:
https://scratch.mit.edu/projects/1258432538/
Anyone knows how can I have the solution to this issue in 0.0.4?:
https://scratch.mit.edu/projects/1258432538/
- Discussion Forums
- » Help with Scripts
-
» Need help with this engine: