E
EZTALES
Guest
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.
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.
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;
}
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.