Anyway, I was programming a simple game since it had been awhile since I used GM, and I ran into an obnoxious bug that I can't kill. I have a collision event where the obj_player contacts a goal of sorts (obj_goal). A variety of things are supposed to happen in this collision, obj_player returns to its starting position, the goal may change its variable, and depending on the goals variable the player may or may not lose a life. All of this works fine. But the goal is also supposed to change sprites during this collision and no matter what I try it just won't work.
So far I have tried using the aforementioned variable to determine in the step event if the sprite_index changes, and I have tried using a similar method in the draw event. In the player object I've changed the variable (during the collision event), and when that didn't work, tried changing the sprite_index itself (using other.sprite_index). I went inside the goal object's collision event and did the same thing (change the variable, didn't work. Change the sprite_index itself, didn't work.)
I've been connected it to a variable because the variable decides whether or not the player loses a life during a collision (which works) and the change in sprites is supposed to alert the player if they're going to lose a life or not (since it's fairly difficult to keep track of mentally which goals are going to kill you.) Which reminds me --there are multiple goals on the screen at the same time, in case that is part of the problem. (All the changing the variable in one does not change the variable in others).
Here's the actual (current) code:
//In the collision event of obj_player
if (other.claim==0)
{
other.sprite_index=spr_claim;
x=288;
y=416;
hspeed=0;
other.claim=1;
}
else if (other.claim==1)
{
x=288;
y=416;
hspeed=0;
life-=1;
}
So yeah, I'm stumped. What really doesn't make sense to me is why this is the only part of the code that doesn't work, when the rest of the code block does.
Any suggestions would be very much appreciated.
Edited by KK Twain, 22 April 2012 - 04:47 PM.











