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 10002 does not exist" with AGK handling the numbers

Author
Message
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 4th Oct 2013 23:02
I tried to add particles on my menu screen and received the error in the title of this post. I moved the function that created the particles to be after the menu screen function and then all was okay.

I am letting the AppGameKit IDE/Compiler handle the sprite enumeration.

The order of calling the functions determined whether or not there was an error.

So, I saw this as a bug and copied/pasted the code to another project file so I could send it for analysis. But the duplicated code demonstrates the same error no matter what order the functions are called. Same code, different behavior.

So now I would like to send this example code, with media so that it is exactly the same, to a TGC affiliate for analysis. How do I get a .zip file of everything to someone?

Remember that this code is working on my original project if I call the functions in a certain order, but does not work in any order in the duplicated (copied) code. I verified that the code is the same.
This shows me that there is an inconsistancy in how AppGameKit is interpreting the code.

And this only happens when I am using particles.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Auger
13
Years of Service
User Offline
Joined: 21st Aug 2011
Location: Out There
Posted: 4th Oct 2013 23:12
Can you post a snippet. Maybe someone here can spot something.


Auger
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 4th Oct 2013 23:46
Can't upload all the files here.

And there is too much code to call a snippet.

In the past I submit snippets and I get told that the problem cannot be reproduced. So I need to include everything involved, especially since it involves the order in which the functions are called with animated sprites and particles. Without the same files how would you isolate for sure what the issue is??

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Oct 2013 00:07 Edited at: 5th Oct 2013 00:08
Quote: "In the past I submit snippets and I get told that the problem cannot be reproduced."

I haven't seen any of your snippets posted in the forums that weren't dealt with and your issues resolved.

In fact, I've helped you with quite a few.

If you are referring to issue #604, I was not able to reproduce the error discussed using the code posted. Maybe someone else can get the same results as you. If so, could they please add their input to the Google issue. It is also possible that the issue is your graphics hardware in combination with DirectX.

One of the other things that sometimes happens with the AppGameKit IDE (and it has been noted before and TGC is aware of it) is that the compiler doesn't always recognize that code has changed and doesn't always actually recompile the byte code file. So some of the weird test results when you add/remove/move code might be caused by that.

In order to make sure that the compiler actually does cleanly compile (and I have requested a 'Clean' button for the IDE that should do this), manually delete the following files from your project directory ('projname' is the name of the AppGameKit project and its directory):
projname\projname.exe (this is not actually compiled, just the interpreter renamed)
projname\media\projname.byc
projname\media\SourceCode.*

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Oct 2013 02:16 Edited at: 5th Oct 2013 02:25
This is a separate issue than 604. I have not submitted a bug on this one.

There are more issues than you are aware of that have not been resolved by me posting snippets. I am also referring to DBPro issues from the past.

I have already been deleting the .byc, sourcecode.txt and the .exe files whenever I have issues. This exercise does not remedy this particular issue.

To what Google issue are you referring?

This issue has to do with the AppGameKit assigning a value to the sprite ID. I allow it to assign the values on its own, I do not assign any. But after compiling there is an error that 10002 does not exist within the same function/code as it was assigned two or three lines earlier. As I have mentioned in my original post, this has only happened using particles as I have been using several sprites in this project and a previous project without any issues like this.

For those of you that automatically assume that I do not troubleshoot before posting, I have spent 5 hours on this today trying to find out why the error occurs the way that it does. I have gotten it to work without error by having the particles created after the animated sprite. If I create them before the animated sprite then I get the error. So the error would have to be in the particle function. But when you look at the particle function it is just like the example code that came with the product, except that I am allowing the compiler to assign the IDs instead of assigning them myself.

Since everyone needs to see code without the associated files that may be affecting the results... here ya go...








I have left comments near the beginning of the MENU() function describing actions that allow the error and not allow the error. The suspect function is remmed out so that the codes execution will run just fine. By allowing that function (which adds particles) to run the Sprite not found error occurs.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Oct 2013 02:30 Edited at: 5th Oct 2013 02:33
if you delete a sprite better set the variable always to =0 to prevent wrong usage later somewhere.
DeleteSprite(menuButton[cButton].sprButton)
menuButton[cButton].sprButton=0

thats not good because you did not handle the image.
menuButton[ b ].sprButton=CreateSprite(LoadImage("IMAGE\MENU\"+(menuButton[ b ].fileButton)+".png"))
better
menuButton[ b ].sprButton=LoadSprite("IMAGE\MENU\"+menuButton[ b].fileButton+".png")

also this, only at end the image will be freed
SetParticlesImage(sprParticle2,LoadImage("star.png" ) )
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Oct 2013 03:42 Edited at: 5th Oct 2013 03:47
Thanks for the advice on the deleting sprites and setting the id to zero.

Did you see any reason why there would be the error I mention?? The error happens before ever reaching the delete, so the delete doesn\'t happen. I\'ll check to see if I am deleting sprites somewhere else which may be causing my issue. But I am sure I have only one DeleteSprite command so far.

I put the parenthesis around \'menuButton[b].fileButton\' because I was getting an error and thought the compiler was being captious.

I like how my code creates a bold tag.

How did you submit without that happening?

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Oct 2013 03:51 Edited at: 5th Oct 2013 03:52
The bold tag happens if you do anything in your post that looks like left square bracket '[' and 'b'.

Quote: "To what Google issue are you referring?"

#604

Let's start with this code:

Do the SetTextString and SetTextVisible outside of the while loop, just to optimize. Once both are called, they don't need to be called until either one changes. You are probably creating a memory issue with this. I don't know how good AppGameKit is at garbage collection. The SetTextVisible command is not a real issue. But the SetTextString one might be.

Then we get to the MENU function:
1. You reference and set CREATE_MENU_BACKGROUND. But, since it is not declared a global variable, it never gets changed. AppGameKit defaults all undefined variables to zero. Probably not an issue because you only actually call the function once.
2. Why do you have the delay loop? Let the code run as it will. On different devices you will get different timing.

In the same function, because you call PlaySprite every time the function is called, it resets to the start of the play (we have gone over this in another post).

Your Sync() call in the for loop in CREATE_MENU_BG serves no function at this point. If you must, call it once after the loop.

You should use '/' instead of '\' in your file names. In Windows, you will probably get away with it. If you ever convert to Tier 2, this will bite you in the butt. I am assuming that the compiler cleanly converts this to '/' which is used in all other platforms. I actually wouldn't be surprised if it recognized '\' as the escape character and all of your load statements are not working as a result.

In CREATE_MENU_BUTTONS:
1. Why are you returning returning numSprFrames when you don't store or use it in the place that it is called?
2. Why do you set numSprFrames inside the do loop and it never changes?
3. You set a variable named newLocation to 1. If you expected this to work outside the MENU function, it needs to be declared as global.

While the documentation and the prevailing wisdom is that anything declared with 'dim' is automatically global, I have my suspicions about this as it relates to arrays of UDTs. I haven't tested it, but I wouldn't be surprised if that handling wasn't as good as it should be. Arrays and UDTs have been an issue from the beginning. It might not hurt to declare your arrays as global in the functions that use them.

While I was working on this you posted again (and I included my comments about the bold tag at the top). I think your use of '\' instead of '/' might beig some of your issue.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Oct 2013 03:53
I forgot to mention that this is a runtime error, not a compiler error.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Oct 2013 10:59 Edited at: 5th Oct 2013 11:07
you used a wrong variable name spr...
particle id is not a sprite

sprParticle=CreateParticles(screenSize.X/2, 0 )
SetSpriteDepth( sprParticle, 2 )

i am sure you mean SetParticlesDepth

--------- other illustration about my remark above
img=loadimage("...")
spr=Createsprite(img)
deletesprite(spr)
deleteimage(img)
-------------
spr=Createsprite(loadimage("..."))
deletesprite(spr)
deleteimage(???)
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Oct 2013 19:57 Edited at: 5th Oct 2013 20:26
I think Markus won the prize. Stay tuned..

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Oct 2013 20:31
That was it! I was so used to typing Sprite instead of Particles because I was thinking how the particles ARE sprites.

But that still leaves the issues...

1) Why does it work for me if I create the sprites after the animated sprite, but not before the animated sprite?
2) Why did the depth actually work? Before I added the depth command the particles were on top of my animated sprite. When I added the command the particles were behind the sprite. Hmm...

Inconsistencies in the compiler?

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Oct 2013 20:55
As for the other comments, though a couple are helping with the idiosynchracies of AppGameKit, are about the fact that I am not finished with the code. Also, there are remnants from experimentation.

AGK does not allow anything on top of video, so I had to innovate. I tried a couple of ideas and one was to change the sprite image in the input wait loop. But that was playing the video too fast so I added a delay.

Some of the other code questions come from me "thinking ahead". I will be using those unused variables when I am finished. There is like 5 times more code than what you see in my snippet. What I submitted was the isolated issue version. 'numSprFrames' and 'newLocation' will be used. I promise.

SetTextString in a loop... experiment. It was showing until I did that. But later I took it out and placed it before the loop and works just fine. (This could be case to delete the .byc file)

Irrelevant SYNC() commands... experiment. I had noticed that when I make a change to a video, sprite or even text, that it doesn't always update with one SYNC() command. Thus the redundancy.

My use of PlaySprite in the MENU() function is just fine. I call it when, and only when, I need to display the Menu. The animated sprite is there in lieu of a video. In other words, I can't put anything on to of a video, so I am using an animated sprite as a video. Is that against the rules? Upon leaving the menu the animated sprite is stopped and deleted.

I changed all the '\' to '/'. I didn't know it would work in Basic.

The UDT arrays are working globally. If I make an array a global even though it already is a global, would that cause its own issue?

Now I know I need to see an optometrist. Or should I say perceptimetrist? I looked at the particle code several times and always saw SetParticleDepth. Or I just need to stop copy and pasting everything. Sometimes clone disease sets in.

Thanks.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 5th Oct 2013 20:56
Issue #604 is a different issue.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Oct 2013 23:55
I need to apologize. I was in a very bad mood when last I posted (my husband only got back today after being away for three weeks) and what I posted was picky and just not nice.

Quote: "If I make an array a global even though it already is a global, would that cause its own issue?"

No, it is just being explicit (and using belts and suspenders).

But, if I mean for something to be global, I always declare it as such, even the arrays. And if you want something to be global, it needs to be declared that in any functions that use it.

Quote: "I looked at the particle code several times and always saw SetParticleDepth."

We have all done this at one time or another. That is why a second set of eyes comes in handy on occasion.

You can set the speed that the animation plays at in the PlaySprite command (second parameter) and then you wouldn't need the delay.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 6th Oct 2013 05:52 Edited at: 6th Oct 2013 05:56
I know about the FPS in the PlaySprite function.

I was using a static sprite and replacing the image in a loop, thus the added delay.

Your post isn't too bad. You should have read the one I deleted.

I keep forgetting not to post anything when frustrated.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)

Login to post a reply

Server time is: 2024-11-24 19:59:39
Your offset time is: 2024-11-24 19:59:39