|
Post by unclechicken on Apr 18, 2015 1:53:18 GMT
I've been trying to do this for a while.
Say, if you collect a key (obj 17) from screen 13, and on screen 3 there is a static deadly sprite (a door), how do I make it so that sprite disappears when the person enters the room and if they have collected the key (obj 17) from screen 13.
Been trying for a while, cant get it working.....
|
|
|
Post by andrewvanbeck on Apr 18, 2015 23:03:25 GMT
Hi Unclechicken,
I have encountered this problem and there are options.
I don't think you can get away from coding each individual door. If you have a spare event type just for doors then that's good, because you can check the screen number and item got check to see if a door should be open. I would use a sprite for the door with its own type, then in the code, check to see if it should open - maybe have a close frame as 0 and an open frame as 1.
if direction 0 let direction = 1 if screen 5 if got 5 animate if frame = 0 remove endif endif endif endif
You would have each room and corresponding key checked like that - only on creation as the direction variable is being used to signify that the sprite has spawned. Effectively when the sprite is being created, it will animate if the player has the correct item then is removed.
To make the door sprite impassible, you can add to the player collision stuff, like a typical player moving up:
if key 0 if cangoup spriteup endif endif
But, because your door sprite has a specific type, you can check for collision with that as well, say your door is event type 4:
if key 0 if cangoup spriteup if collision 4 spritedown endif endif enduf
So if you can go up, but then hit a sprite type 4, then move the opposite direction. You could use this for any solid sprite that you might need, like just check the image at the start to decide what to do - then you only need to check 1 type with the extra collision response.
Hope this helps.
|
|
|
Post by unclechicken on May 11, 2015 0:10:15 GMT
That worked great, thanks.
|
|