• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

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.
 
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