A
azzzanadra
Guest
ok so i am making this platformer ppuzzle game, and i want to change from a room to another, i followed the video on youtube, but when i tried it it takes me to the next room but doesn't take the player object with it.
and the thing is i have another project that i put in the same coding and there it works, so why not here??
here is the code for my player object:
this is the code for the transition object:
and the thing is i have another project that i put in the same coding and there it works, so why not here??
here is the code for my player object:
Code:
create:
///variables
hsp = 0;
vsp = 0;
grav = 0.3;
jumpspeed = 8;
movespeed = 4;
move = 0
image_speed = 0.1
life = 3
step:
//player input:
key_right = keyboard_check(vk_right)
key_left = -keyboard_check(vk_left)
key_jump = keyboard_check(vk_space)
//reaction to input:
move = key_right + key_left
hsp = move * movespeed
if (hsp !=0)
{
sprite_index = spr_move
}
else
{
sprite_index = spr_player
}
if (vsp <0)
{
sprite_index = spr_player
}
if (vsp < 10)
{
vsp += grav
}
if (place_meeting(x,y+1,obj_block))
{
vsp = key_jump * -jumpspeed
}
//horizontal collision:
if (place_meeting(x+hsp,y,obj_block))
{
while (!place_meeting(x+sign(hsp),y,obj_block))
{
x += sign(hsp);
}
hsp = 0
}
x += hsp
//vertical collision:
if (place_meeting(x,y+vsp,obj_block))
{
while (!place_meeting(x,y+sign(vsp),obj_block))
{
y += sign(vsp);
}
vsp = 0
}
y += vsp
//spike
if(place_meeting(x,y,obj_spike))
{
instance_create(x,y,obj_death)
instance_destroy()
}
Code:
collision with player:
obj_player.x = target_x;
obj_player.y = target_y;
room_goto(target_r);
the creation code for the object:
target_x = 160;
target_y = 672;
target_r = rm_2;