Hello, I am new to scratch and have spent a couple of weeks building a game. In my game, I have ghosts that switch from green to white. When the character touches the green ghost and presses the spacebar, I want the score to increase. When the character touches the white ghost and presses the spacebar, I want the score to decrease. I set the character when space key pressed to broadcast touching something good and broadcast touching something bad.
Here is the script when touching the green ghost...
When I receive touching something good
If touching character
wait until costume # 1
change score by 1
hide
wait 1 sec
broadcast new green ghost
end if
Here is the script when touching the white ghost...
When I receive touching something bad
If touching character
wait until costume # 2
broadcast character saying "you lost points"
change score by -1
hide
wait 1 sec
broadcast new white ghost
end if
When I go to run the game and press the spacebar, both scripts turn white. The character makes the announcement whether or not it is on a green or white ghost. The points seem to work though.
Also, I have different backgrounds. The ghosts are only to appear on one of the backgrounds. If I don't get rid of all the ghosts before changing the background, they are still there on the next background. I checked my script for hiding them with different backgrounds and it works correctly. This problem must all be related to the above script.
Any help I could get on resolving this issue would be greatly appreciated.
Offline
one problem is probably the "wait until costume #"; i don't know what that's supposed to do.
i'd try something like:
*this would be the script for each ghost. you could set a variable (use: for this sprite only) which is "green" when they are green and "white" if white. your character can do different things when it receives the "bad touch" and "good touch" broadcasts in its own scripts.whenspace ▼key pressediftouchingcharacter ▼?ifcolor=greenbroadcastgood touch ▼ifcolor=whitebroadcastbad touch ▼when I receivegood touch ▼hidechangescore ▼by1wait1secsgoto x:pick randomy:-220to220pick random-160to160showwhen I receivebad touch ▼hidechangescore ▼by-1wait1secsgoto x:pick randomy:-220to220pick random-160to160show
******when i receiveinitialize ghost level ▼showwhen i receiveleave ghost level ▼hide
Offline