Non-existant object detection!
BlitzPlus Forums/BlitzPlus Beginners Area/Non-existant object detection!
| ||
Bah. I bet something really simple is the answer. I'm making a tower defense game. Turrets shoot enemies. The bullet's supposed to delete itself. I keep getting a "memory access violation". When I ran the game in debug, it said that "object does not exist" that is, "bullet.typBullet". I think it's trying to do collision detection or move the bullet (bullet\x = bullet\x + 5) when there is no bullet, but i don't know how to fix this. any help is nice. |
| ||
In general you test for an object's existence by comparing with Null:If MyObject <> Null Then DoSomethingHowever, in your case I think you could simply do the loops in the other order: first enemy then bullet. Think about what happens after a bullet is deleted. The way the loops are now you move on to the next enemy, still trying to use the current bullet which was just deleted. Thus ImagesCollide fails. |
| ||
Thanks, my problem is solved! If I ever get this thing done, you will be credited for your services. |