• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

A problem with sprites

M

Mariusblock

Guest
I want to make my player change sprites when coliding with an object. Lets say I have 2 objects A and B. When the player colides with obj A the sprite is changed to sprite A and when it colides with B the sprite changes to sprite B. But how to I tell the engine: If the Player has Sprite A after touching obj A and then touches object B the sprite changes from sprite A to sprite C not B.
 

Roderick

Member
On collision with Obj_B:

Code:
if (sprite_index == spr_A)
 {sprite_index = spr_C}
else
 {sprite_index = spr_B}
In English: When colliding with Object B, if the current sprite is A, change to sprite C, otherwise change to sprite B.
 
W

whale_cancer

Guest
How are you handling collisions? Please show some code.

If you are just using collision events, this should be simple. Collision event with obj_a, change to sprite a. Collision event with obj_b, change to sprite b unless it has sprite a, in which case change to sprite c.
 
Top