Pages: 1
Topic closed
Whats the best way to switch between multiple costumes without having a long line of scripts.
This is what I use in most of my games:
<forever>
<if><key[ right ]pressed?>
<switch to costume[ 1 ]
<wait( 0.25 )secsc>
<if><key[ right ]pressed?>
<switch to costume[ 2 ]
<wait( 0.25 )secsc>
<end>
<end>
<end>
But this is a very long script, and lags up a lot of sprites, making it hard to edit the scripts.
The next best one i could think of is this:
<forever>
<if><key[ right ]pressed?>
<repeat until><( costume <=> 3 )>
<if><key[ right ]pressed?>
<next costume>
<wait( 0.25 )secsc>
<else>
<end>
But this has a lot of glitches in it. Any help would be great.
To make it clear, I am looking for a way to switch between costumes of a sprite, without having to create long scripts.
Offline
Look at the code in this project http://scratch.mit.edu/projects/archmage/291819
I see a lot of projects where it is obvious that the person spend hours just making the code for the costumes which is a huge waste of time. The code in my example I posted is perfect, so try to use it.
Offline
archmage wrote:
Look at the code in this project http://scratch.mit.edu/projects/archmage/291819
I see a lot of projects where it is obvious that the person spend hours just making the code for the costumes which is a huge waste of time. The code in my example I posted is perfect, so try to use it.
Thanks! It worked great
One thing I would say though. When using a stance with multiple costumes, for example running, you missed out a wait block. Atm you use this script for stances with multiple costumes:
<switch to costume[1]
<repeat(3)
<wait( 0.05 )secsc>
<next costume>
<end>
This will switch the other first costume, wait 0.05, next costume, wait 0.05, next, wait, next, next costume, as there isn't another wait after you have done the 3 repeats.
So it should look like this:
<switch to costume[1]
<repeat(3)
<wait( 0.05 )secsc>
<next costume>
<end>
<wait( 0.05 )secsc>
Offline
Dan01 wrote:
archmage wrote:
Look at the code in this project http://scratch.mit.edu/projects/archmage/291819
I see a lot of projects where it is obvious that the person spend hours just making the code for the costumes which is a huge waste of time. The code in my example I posted is perfect, so try to use it.Thanks! It worked great
![]()
One thing I would say though. When using a stance with multiple costumes, for example running, you missed out a wait block. Atm you use this script for stances with multiple costumes:
<switch to costume[1]
<repeat(3)
<wait( 0.05 )secsc>
<next costume>
<end>
This will switch the other first costume, wait 0.05, next costume, wait 0.05, next, wait, next, next costume, as there isn't another wait after you have done the 3 repeats.
So it should look like this:
<switch to costume[1]
<repeat(3)
<wait( 0.05 )secsc>
<next costume>
<end>
<wait( 0.05 )secsc>
I guess you are correct. I doesn't make a big difference though.
Offline
archmage wrote:
Dan01 wrote:
archmage wrote:
Look at the code in this project http://scratch.mit.edu/projects/archmage/291819
I see a lot of projects where it is obvious that the person spend hours just making the code for the costumes which is a huge waste of time. The code in my example I posted is perfect, so try to use it.Thanks! It worked great
![]()
One thing I would say though. When using a stance with multiple costumes, for example running, you missed out a wait block. Atm you use this script for stances with multiple costumes:
<switch to costume[1]
<repeat(3)
<wait( 0.05 )secsc>
<next costume>
<end>
This will switch the other first costume, wait 0.05, next costume, wait 0.05, next, wait, next, next costume, as there isn't another wait after you have done the 3 repeats.
So it should look like this:
<switch to costume[1]
<repeat(3)
<wait( 0.05 )secsc>
<next costume>
<end>
<wait( 0.05 )secsc>I guess you are correct. I doesn't make a big difference though.
Suppose not Anyway, thanks for the help
Offline
Topic closed
Pages: 1