Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / White Sprites

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Dec 2011 23:30 Edited at: 6th Dec 2011 23:31
I have encountered a problem as I've built up my game. I can run my menu system perfectly, moving around the different menus and options. Each one starts from nothing and loads the button image, creates sprites and text, then deletes them all after an option is taken. If the option is another menu, it starts all over again. I can do this all day long with no issues.

Once I play the game, the menu graphics lose their transparency, bit by bit (as you can see below it's not all), and ultimately deleted sprites leave white blocks behind. The "Play Game" option is currently just loading three images and sprites, moving them around a bit, then deleting them again.

Any ideas?



Attachments

Login to view attachments
JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 7th Dec 2011 04:53
For me, it seems a problem of graphics memory, or related to its use. Have you done a test on another PC? Its an idea.
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 7th Dec 2011 06:51
I'm not sure about this one BatVink. If you like post the project (or code in question) and I'd be happy to go through it.

Quote: "For me, it seems a problem of graphics memory,"

I've seen that problem too except in this case he seems to be able to load them and draw them and then they disappear. If it were a graphical memory problem I don't think he'd see them at all.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Dec 2011 08:55
Not had this issue. Is there any reason you can't load the images just once? Maybe it's related to reloading the same image over and again after physics or something else has been initialised?

Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 7th Dec 2011 10:24
Don't know about your problem. I don't think you are running out of memory on a PC.

But you should not be loading a ton of button images. It would be best to load a single button background and then create text objects from a custom text image. Should be much faster and take up less memory.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Dec 2011 10:32 Edited at: 7th Dec 2011 10:33
Quote: "But you should not be loading a ton of button images. It would be best to load a single button background and then create text objects from a custom text image. Should be much faster and take up less memory."

I got the impression that's how it's being done already.

Are you using a background image or setting the refresh colour? Maybe it's the screen not fully refreshing? Add a screen sized sprite the same colour as your background behind the menu sprites maybe?

EDIT: One final thought, are you deleting / hiding the sprites or are you just setting the image to zero? A zero imageID would cause a white sprite too...

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Dec 2011 10:40
Quote: "Have you done a test on another PC?"


I get the problem on 2 PCs and an Android phone

Quote: "But you should not be loading a ton of button images. It would be best to load a single button background and then create text objects from a custom text image. Should be much faster and take up less memory."


I load one image and create all buttons from it (Sprite + Text overlaid). When a selection is made, I unload the sprites, image and text. If a new menu is required, I load the image again and repeat.

Quote: "Is there any reason you can't load the images just once? Maybe it's related to reloading the same image over and again after physics or something else has been initialised?"

I will try loading it just once to see what impact this has. The reason for reloading is that this is a standalone piece of code, that I can drop into any project to create menus. Loading the image for each menu makes it more portable and configurable.
There's no physics involved, so this can discounted.

Quote: "Are you using a background image or setting the refresh colour? Maybe it's the screen not fully refreshing? Add a screen sized sprite the same colour as your background behind the menu sprites maybe?"

This may have started when I changed the refresh colour to a dark grey from the default black. I'll check that too

Quote: "are you deleting / hiding the sprites or are you just setting the image to zero? A zero imageID would cause a white sprite too"

I deleteSprite() followed by deleteImage(). But the effect is almost like I deleted the image and the sprite stayed.

I'll report back when I've tested again later, thanks for all the ideas

JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 7th Dec 2011 11:35 Edited at: 7th Dec 2011 11:38
null, sorry.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Dec 2011 16:48 Edited at: 7th Dec 2011 16:48
How do you deleteSprite() and deleteImage()? (post code)

Try like this:

Or like this:


May not change anything, but give it a go and see if it helps.

My signature is NOT a moderator plaything! Stop changing it!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Dec 2011 20:36
I worked it out by not deleting the image at the end of the menu. I had a typo in my code and I wasn't deleting the sprites. So sprites with no image were showing as white.

AGK can be very forgiving, but it can result in the program continuing to run with bugs in it. This is the second time my program has refused to die - it will continue through a divide by zero too

LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 8th Dec 2011 01:12
I am afraid that was my 'bright idea'. The 'app that cannot be killed' is part of the promise that when your app finds itself in a strange land on an alien device, it doesn't turn green and die, it takes a deep breath and gives it a bloody good go, warts and all. We could add some sort of 'sensitive mode' when bombs out the moment something slightly naughty happens with an appropriate error, maybe set in the IDE so you can quickly switch it on/off.

My grand plan was to put this (and more) into the suspiciously absent debugger tool, which would not only stop at the offending line, but show you what it expected, what it got, what it looks like, where it came from, why it happened and a suggestion on what you can do to fix it.

I drink tea, and in my spare time I write software.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Dec 2011 08:22
It's a great bright idea - I think developers need an insight into what will get captured and how it is dealt with. We now know through trial and error a /0 returns 0, and you can deleteSprite() on an invalid id.

The debugging plan sounds good

Login to post a reply

Server time is: 2024-11-22 19:57:13
Your offset time is: 2024-11-22 19:57:13