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 / Sprites show up as white blocks

Author
Message
Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 1st Sep 2011 13:10
Just started a new project to test some code without polluting my main game, and I've got a probelm where sprites are showing up as white blocks. The sprites are PNG files with transparency, and I get the same effect when using the small_ball.png file that ships with the examples.

I've installed the latest version of AppGameKit, but I wouldn't have thought that would cause a problem. My main project runs fine, as do the examples, so it must be something odd that I'm doing, but I'm not sure what.

The code I'm using is:


There's not a lot of point posting a screenshot, as all it will show is a black program window with up to 5 white squares on it where the sprites should be. But I can do it if anyone thinks it will be helpful. The image is located in the 'media' folder under the root of my game, and as expected I get an error if I change the name to one that doesn't exist.

This has got me scratching my head, but odds on it turns out to be something really simple!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Sep 2011 13:18
I had your same problem. If I used a 100% transparent png, it translated into a white block! Putting a pixel somewhere in the image solved the problem!
Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 1st Sep 2011 13:20
No, it's not that - the sprite has content in it. As I said, if I use the small_ball image from the examples, I get the same problem.
RickV
TGC Development Director
24
Years of Service
User Offline
Joined: 27th Apr 2000
Location: United Kingdom
Posted: 1st Sep 2011 13:41
I get the same, I'll send it to Paul to investigate!

Rick

Financial Director
TGC Team
Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 1st Sep 2011 14:12
Quote: "I get the same, I'll send it to Paul to investigate!"

Cheers, at least I know it's not me!
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Sep 2011 15:31 Edited at: 1st Sep 2011 15:41
It is wierd because if you call it straight then it works...


or if you try this
.... it works as well.

So something is going wrong in the array or the user type.


Edit

The problem seems to be with the create sprite
This code gave an error message that the image did not exist


It says that image 1 does not exist at line 30 but we know that it does.

Then if I used clonesprite it worked...



Not sure if this will help any but here it is anyway.

Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 1st Sep 2011 15:33
The variable "ballImage" is not global, so inside the function it is equal to 0, which creates a blank sprite.
Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 1st Sep 2011 15:40
D'oh! Where the facepalm smiley?

Thanks.
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Sep 2011 15:42 Edited at: 1st Sep 2011 16:07
Quote: "The variable "ballImage" is not global, so inside the function it is equal to 0, which creates a blank sprite. "


It still does the same thing even if I deifine it as global...

global ballImage = LoadImage("small_ball.png")


...did you try it paul?

The only thing that worked for me was using a clone instead of creating a sprite in the function (see my snippets above)

Am I the only one that the Global declaration doesn't work for???


Edit
Am I on the pay no mind list or are my posts not showing up?
Anybody????

Declaring the ballImage as global didn't work for me.

Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 1st Sep 2011 16:06
It does work if you do:
Global ballImage
ballImage = LoadImage("small_ball.png")

And that's good enough for me
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 1st Sep 2011 16:09 Edited at: 1st Sep 2011 16:12
Quote: "It does work if you do:
Global ballImage
ballImage = LoadImage("small_ball.png") "


Then what is wrong with

Global ballImage = LoadImage("small_ball.png")

I thought we could declare it as global on the same line as assigning the initial value.
Oh well, let me try that then, because I guess that was my mistake.
I had tried setting it to global before I saw his post, so that is why I thought he hadn't tried it yet.
I didn't know the global declaration had to be on a spearate line.

Thanks


Yeah that worked for me too.
I'll have to remember that thing about the Global being on a separate line.

Sorry guys, I was only trying to help.

Josk
16
Years of Service
User Offline
Joined: 2nd Apr 2008
Location:
Posted: 1st Sep 2011 17:11
I had this happen, when I used Creatsprite I had mispelt the image name.
Zubby1970
AGK Backer
16
Years of Service
User Offline
Joined: 22nd May 2008
Playing: AGK Studio Always
Posted: 1st Sep 2011 19:10
i was just about to say that paul

There can only be one
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 5th Sep 2011 04:58
When you assign a value to a global statement, the data value is used to initialise the variable before the program begins. I can see why the opposite might be assumed on reading your code. My gut feel is to throw up a compiler error if it finds a non-literal data value on the same line as a global declaration so you know what the compiler is thinking. If you can post this to the new issues board, we won't miss it during our fixes:

http://code.google.com/p/agk/issues/list

I drink tea, and in my spare time I write software.

Login to post a reply

Server time is: 2024-11-24 00:21:13
Your offset time is: 2024-11-24 00:21:13