And i've been struggling with 1 simple thing.
When player_1 hits chest then i want a gem to appear on top of that chest.
But i have 6 chests on this level. and i'm stuck
and i also have different coloured gems.
Posted 17 April 2012 - 12:00 PM
Posted 17 April 2012 - 12:04 PM
Posted 17 April 2012 - 12:04 PM
Posted 17 April 2012 - 12:07 PM
Posted 17 April 2012 - 12:11 PM
Posted 17 April 2012 - 12:14 PM
When player_1 hits chest then i want a gem to appear on top of that chest.
has_gem=1;//Does this chest have a gem? 1 = yes, 0 = no
if other.has_gem=1//If the chest we have collided with has a gem in it
{
other.has_gem=0;//It no longer has a gem in it
instance_create(other.x,other.y-32,obj_gem);//Create a gem object above the chest
}Posted 17 April 2012 - 12:24 PM
Posted 17 April 2012 - 12:27 PM
right... i did that but look. i dnt understand it.
___________________________________________
ERROR in
action number 1
of Collision Event with object chest
for object George:
Error in code at line 4:
instance_create(other.x,other.y-32,obj_gemP);//Create a gem object above the chest
^
at position 37: Unknown variable obj_gemP
i named my gem "gemP" btw.
Posted 17 April 2012 - 12:33 PM
Posted 17 April 2012 - 12:40 PM
ok i did that. it doesn't come up with an error. but i think you dnt understand what i ment.
i placed obj_gem on top of the chest, its set to be invisible, so what i want is when George collides with chest i want the obj_gem to become visible.
i could create 6 different chest
and 6 different gems with different colours. Right?
so basically i need one code for one chest. and unfortunately this doesn't work.
obj_gem.visible=1;
Posted 17 April 2012 - 12:50 PM
Posted 17 April 2012 - 12:58 PM
omg i thought this would be difficult.. anyway thanks..
now that this is covered... i just thought of something.. it 's complicated. and i dnt know if it will work.
lets say that he gets the gun in level 1. and level 2 he shoots the chests.
do you know what i mean? and i want George to have a limited amount of bullets like 3 for example.
bullets=3;//Give George 3 bullets
if bullets>0//If George has some bullets
{
i=instance_create(x,y,obj_bullet);//Create a bullet at George's x,y coordinates
i.speed=10;//Give the bullet a speed of 10
i.direction=direction;//Make the bullet travel in the same direction as George*
bullets-=1;//Take away 1 bullet from George's remaining bullets
}obj_gem.visible=1; instance_destroy();//Destroy the bullet
Edited by Soulsnatcher, 17 April 2012 - 12:59 PM.
Posted 17 April 2012 - 01:16 PM
Posted 17 April 2012 - 01:21 PM
thanks in my case i dnt use vspeed and hspeed i use simple key press commands for the player. it still works.
i made my George change its sprite so he looks left if i press A and so on. and i also want the bullet to change the sprite from left to right. i created diff sprites for the bullet btw.
if bullets>0//If George has some bullets
{
i=instance_create(x,y,obj_bullet);//Create a bullet at George's x,y coordinates
i.speed=10;//Give the bullet a speed of 10
if sprite_index=spr_left//If George is facing left
{
i.direction=180;//Set the bullets direction to left
i.sprite_index=spr_bullet_left;//Set the bullets sprite to the left facing bullet
}
else
if sprite_index=spr_right//else if George is facing right
{
i.direction=0;//Set the bullets direction to right
i.sprite_index=spr_bullet_right;//Set the bullets sprite to the right facing bullet
}
bullets-=1;//Take away 1 bullet from George's remaining bullets
}Edited by Soulsnatcher, 17 April 2012 - 01:22 PM.
Posted 17 April 2012 - 01:37 PM
Posted 17 April 2012 - 01:50 PM
will there be an easier way of changing the sprite of the gem? but for different chests.. instead of creating 6 different chests for 6 different gems.
//chest opening code
with instance_nearest(x,y,obj_gem)
{
visible=1;//Set the nearest gem to this chest to be visible
}sprite_index=spr_gem_red;//Make this gem's sprite be the red gem sprite
Posted 17 April 2012 - 02:01 PM
Posted 17 April 2012 - 02:03 PM
when the bullet hits a chest all the gems become visible.
Posted 17 April 2012 - 02:07 PM
Posted 17 April 2012 - 02:07 PM
yeah
obj_gem.visible=1; instance_destroy();//Destroy the bullet
with instance_nearest(x,y,obj_gem)
{
visible=1;
}
instance_destroy();//Destroy the bulletEdited by Soulsnatcher, 17 April 2012 - 02:08 PM.
0 members, 0 guests, 0 anonymous users