GENSPRITE() problem

Previous topic - Next topic

okee

Having trouble with GENSPRITE() anytime i use it the program
builds but i get the message Start debug session.
but the program doesn't run
if i change GENSPRITE() to an actual number it runs fine
I might be overlooking something but right now i don't know what ...

Code (glbasic) Select


SETCURRENTDIR("Media") // seperate media and binaries?
GLOBAL sprPlayer = GENSPRITE()
LOADSPRITE "player.png",sprPlayer

GLOBAL Quit = 0
SETSCREEN 320,480,0
WHILE Quit <> 1

DRAWSPRITE sprPlayer,0,0
SHOWSCREEN
WEND
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

MrTAToad

Certainly does - however : as mentioned elsewhere, RGB is the only command that can be used to initialise variables.  Any other command causes...problems...

okee

It seems to work without the global declaration in debug/non debug and
running the executable file.
Android: Samsung Galaxy S2 -  ZTE Blade (Orange San Francisco) - Ainol Novo 7 Aurora 2
IOS: 2 x Ipod Touch (1G)

MrTAToad

#3
Yes, it would do..

GLOBAL sprPlayer = GENSPRITE()

and

sprPlayer = GENSPRITE()

are slightly different.  The first specificly defines the type of variable whilst the second would leave to the compiler, with the result that if its invalid for the area where you are defining the variable, you will get either warning or an error - it will only work if you don't enable explicit declarations.

It would be nice if the compiler could spot this sort of thing and stop compiling with an error or something (perhaps only if explicit declarations are on).

FutureCow

I would like to see the compiler flag an error when declaring globals with a variable too!

Kitty Hello

Yes, but that's really hard to program for me. I tried several times already :/