I’m making a game in which you have to pick up a key first with your character and then go to the door. When you hit the door, you should go to the next frame. Without the key, you can’t pass the door. You should pick up the key with hitTestObject and go to the next frame with hitTestObject too.
Could someone help me? Thanks!
Here is my code:
var gotKey:Boolean = false;
if(Jack.hitTestObject (unlock))
{
unlock.visible = false;
gotKey == true;
trace ("You got the key!")
}
if (Jack.hitTestObject (house))
{
if (gotKey == true)
nextFrame();
trace ("level achieved")
}
Are you getting a compile error, or are you looking for help with the logic? Because what you’ve got should work, but you’ve left out a set of curly braces on the gotKey logic check where Jack hitTestObjects house.
should be