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 / Issue with 'createSprite' function

Author
Message
CodeTrasher
12
Years of Service
User Offline
Joined: 18th Jul 2012
Location: Tampere, Finland
Posted: 13th Nov 2014 21:26
Hello!

I hope someone could help me with this one... After over a year period of not being able to code with AppGameKit, I finally have a chance to do so, and I've started to work on a simple Pong project.

I have structured my game into several files, and now I'm having a problem with creating a sprite. I created a UDT for Paddle object with random ID, and I am trying to assign the generated spriteID from createSprite(0) call to Paddle.ID. My program compiles without errors but when I try to execute the game, the following error pops up: "Sprite xxx does not exist at line 7 in game_control.agc". I'll paste some snippets to demonstrate my program flow.

// main.agc



// setup_game.agc



// globals.agc



// game_controls.agc


I hope I provided enough information for you guys and can help me spot what I'm missing here!

Thanks in advance!
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 14th Nov 2014 05:45
Your code looks fine to me.
What version of AppGameKit are you using? Maybe there's a weird bug in the version you're using with UDT globals?
If you're using anything less than the latest for AGKv1 then you should update.
Other than that...
try using just a regular variable for the sprite ID and pass it to SetSPriteColor()
Before calling SetSpriteColor() try
if GetSpriteExists(spriteID) = 0
Message("what happened to my sprite = " + str(spriteID))
endif

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Nov 2014 10:04
If you are using an older version of AppGameKit you might need to initialise your types in the main.agc file. It's not an issue in V2 though.
CodeTrasher
12
Years of Service
User Offline
Joined: 18th Jul 2012
Location: Tampere, Finland
Posted: 14th Nov 2014 11:14
Yes, I'm using AppGameKit v1 and downloaded it two weeks ago but I haven't checked if there was a newer version available.

I guess I have to reorganize my code a bit and place mh UDTs inside main file. Thanks for your help, guys!

Login to post a reply

Server time is: 2024-11-25 11:20:33
Your offset time is: 2024-11-25 11:20:33