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 / Sprite images sometimes loading as white boxes - sometimes not.

Author
Message
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 11th Jan 2017 03:40 Edited at: 11th Jan 2017 03:44
Hi all, so in the store section of my game I have a system where users can scroll through purchasable items. I do this by having a select/case statement which loads the currently selected item image based on the index the player is on. Sometimes when I run the app, I'll have a certain image not load and instead just display as a white box. If I scroll past it then scroll back, it will load just fine, so it's not a bad filename and instead seems to be related to the loading procedure. The images I'm loading are fairly small sprite sheets (they go into animated sprites) but are only 71kb apiece. They are, however, PNGs with transparency (I just use alpha masking, though, and not semitransparent pixels). Instead of showing up as the dreaded checkerbox with the red cross, they just show up as a white box the size of the sprite itself.

Has anyone else experienced this? Is there perhaps some way to assure that an image has been loaded correctly before applying it to a sprite using SetSpriteImage?

Thanks in advance.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Jan 2017 07:43 Edited at: 11th Jan 2017 11:44
a white box i get if me using a image id 0 at createsprite.
u using #option_explicit at top in your main.agc? it can help.
also Print("...") is good for debug tracking.
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Jan 2017 08:51
Trying running in debug mode and checking the Console window. It reports any issues with loading images.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 11th Jan 2017 09:02
Are you able to put a code snippet together that shows the problem?

Perhaps the image hadn't loaded by the time you used it due to all the thrashing from trying to load images on the fly (I don't know if that's even a thing, but sounds feasible)? I'd have thought you'd be better off pre-loading all the required images. Also, maybe try bundling all the mini sprite sheets into one big sprite sheet?
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 11th Jan 2017 14:34
I've been keeping an eye on the data as my first thought was that it was grabbing the wrong reference number, but all of my console output and debugging has shown that the correct references are being generated, so I'm assuming it actually IS something like CJB was suggesting, however unlikely...

Unfortunately though I've tried to replicate it on a smaller scale with more specific code, it just isn't happening. This game has turned into one of those huge, convoluted monstrosities where taking out a slice to show doesn't give enough of a picture, lamentably...
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Jan 2017 15:13
How about putting in a temporary slow down, maybe pausing for 100ms between image loads to see if it helps anything.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Jan 2017 18:35
if u using DeleteImage(img) anywhere
do also img=0 after this.
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 11th Jan 2017 20:20
I haven't used AGK2 for very long but I ran into a very similar issue and found that I needed to explicitly set transparency for the sprited with the SetSpriteTransparent (or whatever it is) command.

IIRC this only happened in the HTML5 exports of my games BUT seeing as it was the exact same behavior as you are describing (only some sprites were showing as white rectangles) it might be worth testing this on your end.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
Alien Menace
AGK Developer
19
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Earth (just visiting)
Posted: 11th Jan 2017 22:09
I have run into this too when loading a level in my level editor. Sometimes it works, sometimes it doesn't.
I love my Altair 8800 Replica.

http://altairclone.com/
CumQuaT
AGK Master
14
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 12th Jan 2017 02:37
I'll try the artificial delay and the transparency setting and get back to you guys!
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Mar 2017 00:58
Quote: "Hard to tell without code what is happening"


The following will help if the transparency isn't being set proper

SetSpriteTransparency( iSpriteIndex, mode )
mode - The transparency mode for this sprite, 0=off, 1=alpha transparency, 2=additive blending
SetImageTransparentColor( iImage, r, g, b )
iImage - The ID of the image to change.
r - The red component of the color to set as transparent
g - The red component of the color to set as transparent
b - The red component of the color to set as transparent


If the back ground color isn't being cleared when sync or swap are called
EnableClearColor( clear )
clear - Set to 1 to clear the frame buffer, 0 to not clear it.
fubar
greycheek
8
Years of Service
User Offline
Joined: 13th Mar 2016
Location:
Posted: 21st Apr 2017 18:09
having the same issue with a sprite showing up as a white box; transparency setting doesn't have any effect.

Login to post a reply

Server time is: 2024-11-24 16:26:55
Your offset time is: 2024-11-24 16:26:55