This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-07-16 12:53:57

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Costume change by variable

I didn't realise, but when changing costume by variable, it counts the costumes along a list, rather than jumping to the costume with the name correspending to that variable.

EG, if I have a costume named "211" which is 10th on the list, "Switch to costume (varaiable)" where variable = "211" will not switch to that costume. 

Is this intentional?


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#2 2007-07-16 20:53:48

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Costume change by variable

Yes, the names are not numbers, just strings.  The costumes are numbered in order starting from 1, no matter what names they are given.  You can move the costumes around to change their order without changing their names, or change their names without changing their order.

Offline

 

#3 2007-07-17 02:22:04

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Costume change by variable

A shame - I have a 3d maze game that was going to select the right view by choosing the costume using a 3 digit variable based on the players location on a grid ( X-cordinate, Y-Cordinate and direction faced).

Can still be done, but requires a chain of if statements instead, one for each combination of position and direction.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#4 2007-07-20 02:35:22

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Costume change by variable

No, you can use a computed costume---you just have to be careful to put the costumes in the right order so that you can access them by number.  Use a computation like
  round(x / 60)*8 + round(y /80)*2 + round(direction/180)  + 41

Offline

 

Board footer