Objects not hiding

Post Reply
tarlkea
Posts: 5
Joined: Sun Sep 05, 2010 5:51 am

Objects not hiding

Post by tarlkea » Sun Apr 20, 2014 1:08 am

When I have an object collide with another, I have it set so that it is hidden, so it should no longer render. I checked my debug console output in no$gba and it set to hidden, but it still gets rendered. For example, with bullets when it hits a monster it should disappear, however it is set to hidden but it doesn't disappear. Further more to my confusion is if I fire enough bullets to loop through the array again, the bullet disappears from its static position and gets fired again!

The same thing happens to the monsters. Here is an image of what is happening. I'm setting the hidden attribute to true, and I'm sure the OAM is getting updated through oamUpdate.
Any ideas?
Image

tarlkea
Posts: 5
Joined: Sun Sep 05, 2010 5:51 am

Re: Objects not hiding

Post by tarlkea » Sun Apr 20, 2014 2:29 pm

Dumb coding mistake on my end. I was setting its member variable "alive" to false and "hidden" to true. Then when the oamSet was only being called for the object if it was alive, so it wouldn't update.

WinterMute
Site Admin
Posts: 1989
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Objects not hiding

Post by WinterMute » Sun Apr 20, 2014 2:36 pm

It sounds like you're making the common mistake of allocating specific OAM entries to specific game objects which can lead to problems later if you have more game objects than available OAM entries.

Rather than having an object that's inactive set a corresponding entry in the OAM as hidden it's better to allocate the next available OAM slot to an object which is active. Once you've done this for all the active objects (or run out of OAM entries to allocate) then you simply set the remaining OAM entries as hidden.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests