• Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!

Legacy GM problem changing sprite

EZTALES

Member
hey yall,
imhaving a problem with a sprite change and collsion detection
my code is down below and was wondering if anyone could help. basiclly the problem is when a drop of oil falls from the ceiling and lands in my players bucket, it should set the my score which is global.throwbucket to += 1 everytime. then it changes the players sprite. when it gets to 4 it it should set it back to 0 and sets the players sprite back to the first sprite that i made for it. issue is is that it doesnt even pick up the collision with the player and it doesnt change sprites.
Code:
Information about object: obj_oilman
Sprite: spr_oilman
Solid: false
Visible: true
Depth: -103
Persistent: false
Parent:
Children:
Mask:

No Physics Object
Create Event:

execute code:

image_index = 2;
image_speed = 0;


Step Event:

execute code:

///Control
if keyboard_check_pressed(vk_left) or gamepad_button_check_pressed(0,gp_padl)
{
if image_index > 0
{image_index -= 1}
}

if keyboard_check_pressed(vk_right) or gamepad_button_check_pressed(0,gp_padr)
{
if image_index < (image_number - 1)
{image_index += 1;}
}

execute code:

///Audio
if keyboard_check_pressed(vk_right)  or gamepad_button_check_pressed(0,gp_padr)
{
audio_play_sound(snd_gm9,10,0)
}
if keyboard_check_pressed(vk_left) or gamepad_button_check_pressed(0,gp_padl)
{
audio_play_sound(snd_gm9,10,0)
}

execute code:

///change sprites
/// first sprite
if global.throwbucket = 1
{
object_set_sprite(2,spr_oilman_2)
}
/// second sprite
if global.throwbucket = 2
{
object_set_sprite(2,spr_oilman_3)
}
/// last sprite
if global.throwbucket = 3
{
object_set_sprite(2,spr_oilman_4)
}
/// lose sprite
if global.throwbucket = 4
{
object_set_sprite(2,spr_oilman)
global.throwbucket = 0;
}
Code:
Information about object: obj_drops
Sprite: spr_drops_1
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:

No Physics Object
Create Event:

execute code:

image_speed = 0.1

Step Event:

execute code:

if sprite_index = 9 or sprite_index = 10 or sprite_index = 11 && place_meeting (x,y, obj_oilman)
{
global.throwbucket =+ 1;
}
Information about object: obj_global_throwbucket
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

global.throwbucket = 0
thanks! and there is a little video down below just so you get a idea.
 

zATARA_0

Member
Is the bucket part of the oilman sprite? If so maybe the collision_mask of that sprite isn't properly aligned. It seems like you are checking if the drop's sprite_index is 9,10 or 11, which is probably never true.

Also just as an aside I'd recommend using () in your if statements, like "if((a or b or c) and (d)),
 

EZTALES

Member
Is the bucket part of the oilman sprite? If so maybe the collision_mask of that sprite isn't properly aligned. It seems like you are checking if the drop's sprite_index is 9,10 or 11, which is probably never true.

Also just as an aside I'd recommend using () in your if statements, like "if((a or b or c) and (d)),
thanks, i got it working again but now having trouble with another problem. i made a thread for it here https://forum.yoyogames.com/index.php?threads/only-go-to-sprite-if-global-1.63256/
 
Top