I have a series of objects that represent 1 spear. The spear on the ground I pick up and hold, the spear that's thrown in the air, and the spear that sticks into the wall/objects.
I have it set up so that the spear turns with my character. If I face left the spear uses the left sprite, right gets the right sprite. The ground/held sprite and the in the air sprite all tell the next object what sprite to use.
Now my character can walk up to a spear in a wall and pull it out. The spear drops to the ground and then I can pick it up.
This is the code I use to pull the spear out.
if global.SpearInHand = 1 { exit; } //checks to make sure you can only have 1 spear and not pull another spear out of the wall
if global.SpearInHand = 0
{
if collision_rectangle(x-22,y-3,x+53,y+2,MyCharacter,1,1) >= 0 ///makes sure you're touching the spear
{
instance_create(x,y,spear); instance_destroy(); exit;
}
}I know I can use i = instance_create(x,y,spear); with (i) { bla bla bla }I'm not sure what variable I can check to see which sprite is used by the spear in the wall.
Any ideas?
Edited by Odb718, 31 October 2008 - 09:23 AM.











