|
Post by fadgeplaysgames on Dec 22, 2017 11:21:17 GMT
Alright there everyone, got another question. How do I change the player sprite when the player dies? e.g. the player falls into a pit and the sprite changes to an image of the character splattered horribly on the ground? I tried changing the spriteimage in the character event when the player is killed but that doesnt seem to work.
|
|
|
Post by alessandro on Dec 25, 2017 14:56:24 GMT
You must substitute the player sprite, as soon as it is touched by an enemy, with another sprite, with a different event code. Just changing the sprite image won't work.
The way I did it: I employ a variable to check whether the contact with sprite 0 (player) has occurred. In this case, the player sprite is replaced by another, displaying the death animation, and in this sprite's event code, that variable is increased until it reaches a certain value (say 40). Then, the death animation sprite is removed, a life is subtracted to the player until LIVES > 0, and the screen is restarted - and the death check variable is set back to 0.
|
|
|
Post by zynaps2017 on Dec 25, 2017 20:35:15 GMT
In the player event (TYPE 0):
IF DEADLY ...LET E 1 ENDIF IF E = 1 ..REMOVE ..LET TYPE 8 ENDIF
In enemy TYPE:
IF COLLISION 0 ..LET E 1 ENDIF
In TYPE 8:
LET IMAGE 10 IF B=0 ..ANIMATE ENDIF IF FRAME 4 ..KILL ..DELAY 50 ENDIF
NOTES: -In this example, i chose the letter "E" as the variable to activate the death animation sprite, which is type 8. The variable B is to slow the death animation (*see the example below). -Put in GAME INITIALISATION andR ESTART SCREEN events: LET E 0 -In the death animation sprite, the last frame must be repeated to the last one or empty. So choose the last frame in TYPE 8 to kill the player (in the example above, is the frame nº 4). This is because the last frame is not showned in the animation (i don't know why). So if it doesn´t work, choose the previous frame.
(*)The slow sprite variable in MAIN LOOP 1
IF B = 5 ..LET B 0 ELSE ..ADD 1 TO B ENDIF
|
|
|
Post by fadgeplaysgames on Dec 26, 2017 2:18:52 GMT
great THANKYOU!
But does this mean I need to sacrifice a sprite type just to have a death animation? If so, it may not be possible in the current game Im working on, no biggie, its just a little practice game but at least I know how to do it now.
|
|
|
Post by alessandro on Dec 31, 2017 23:36:06 GMT
great THANKYOU! But does this mean I need to sacrifice a sprite type just to have a death animation? No. A single sprite event can be associated to different behaviors, according to its image. For instance: IF IMAGE = 0 ... ENDIF
IF IMAGE = 1 ... ENDIF and so on. This way a single sprite event can contain more than just one script. However with main sprite events it is always advisable to keep to one script per event.
|
|