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 xxx does not exist

Author
Message
Abiz
11
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 21st Jan 2013 16:48
I have this piece of code:


How can I get this error:
Sprite 68391680 does not exist at line 44 in xxx.agc


The number can a.o. also be 68879240 or 15991424.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 21st Jan 2013 17:15 Edited at: 21st Jan 2013 17:16
Can you show the code where you set up the sprites?

Also, using goto's is not the best programming style (even though it is allowed). And might cause stack issues if you are in subroutines or functions. It would be better to use nested ifs:

The code above is much easier to read, flow wise, and much easier to debug.

EDIT: What version of AppGameKit are you using? (The exact one can be found near the top of the AGK\AGK.txt file.)

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Abiz
11
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 21st Jan 2013 17:25
06/06/12 - Build 1076
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 21st Jan 2013 17:32
Can you please try my posted code suggestion and see if it makes a difference?

It is not entirely impossible that the "if <x> then goto" combination is not working correctly. People have encountered some strange things on the single line if statement.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Abiz
11
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 21st Jan 2013 17:57
Tested it, and it makes no difference.
Abiz
11
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 21st Jan 2013 18:09
To avoid the problem for now I've added these 2 lines:


PS: I've had the 'goto' discussion for 35+ years now, and I do not agree entirely with you. Goto is perfectly useful in certain situations. Especially here, instead of endless IF and ENDIF.
Just my 0,02
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 21st Jan 2013 19:00
That takes care of the problem, but doesn't explain why it happens. The GetContactSpriteID1/2 commands should not be returning a sprite id that doesn't exist.

We don't need to get into an argument over 'GoTo'. I made the suggestion because I thought you might be new to programming (the ratio of seriously experienced to the less experienced is very low on this site) and it is easy to get into trouble using them if you don't have a lot of experience. But, with 35+ years experience you are absolutely right to program any way that works best for you.

Actually everyone is right to program however it works best for them, I'm just a little prejudiced about GoTo and how it can make debugging trickier. I've seen too many places where it's been badly used with subroutines (jumping into the middle of one or out of one and messing up the stack).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 21st Jan 2013 19:00
Irrespective of programming style or layout, the problem stems from the fact that one of the variables contains an invalid sprite reference.

Quote: "Sprite 68391680 does not exist at line 44 in xxx.agc"


Because of the way errors are reported, without seeing the entire code, we can't be sure that the line in the error (44) refers to the line shown as line 44 in the IDE. That's a whole other subject.

The best solution is the old-school one (so with 35+ years experience should be easy )

After each instruction, write a line to a log file, indicating which instruction just ran and what the sprite variables currently contain.
eg.
'Just ran: sID1 = GetContactSpriteID1(), sID1 = xxxx , sID2 = yyyy'

When the app fails, look at the log to see where the bogus number appears and you're golden.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 21st Jan 2013 19:22
I don't know if they fixed it (I think they did), but it used to be that the line reported was actually 5 lines before (or after?) the actual line that had the error.

Try checking the lines after the last check, where you actually do something with the two sprite ids.

There have also been cases where simply putting a dummy print or something fixes the issues. Sometimes the AppGameKit Basic compiler does funny things.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-03 22:15:03
Your offset time is: 2024-05-03 22:15:03