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 / Automatic media ID's

Author
Message
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 23rd Oct 2012 16:41 Edited at: 23rd Oct 2012 16:46
Hello, in the game im working on, I have quite a few sprites. about 15000 I think. But I noticed something when working on menus today, when i go back to the main menu, I clear all media with this code


I started it at 10000, but when I went back to the menu, the sprites used there didn't show up. So I changed to 20000, and it worked, but only the first time. when I started the game and went back to the menu again the sprites didn't show up. When I changed it to 50k, I can go back to the menu a few times, but after a while, it dosn't show up. This suggests that when you delete a sprite, the ID slot dosn't open up again and the game creates new sprites with higher ID's. Is this the case, and is there a way to avoid it. Because when you get up to 50000 sprites to chek, you start to notice a short black screen.

Edit The effect is defenitivley noticable on an android device.

Also, come to think of it, the math dosn't add up, my game uses 10k sprites for the ground, and about 5k for plants ect. That means that there are 15k sprites, and automatic sprite ID's start at 10k. Therefore, after 1 run, the highest sprite ID should be 25k, but the menu loads fine when only 20k sprites are deleted. Do you have any idea about what could be causing this.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 23rd Oct 2012 17:32
I'll add the commands DeleteAllImages, DeleteAllSprites, and DeleteAllText that will clear all numbered items and reset the auto ID to 10000
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 23rd Oct 2012 18:48
As a workaround for now perhaps using GetManagedSpriteCount() as the number of sprites loaded may work?

The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 23rd Oct 2012 19:43 Edited at: 23rd Oct 2012 19:44
Quote: "I'll add the commands DeleteAllImages, DeleteAllSprites, and DeleteAllText that will clear all numbered items and reset the auto ID to 10000"
Ohh, that sounds usefull.

Quote: "As a workaround for now perhaps using GetManagedSpriteCount() as the number of sprites loaded may work?"
That may help in some way...
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 24th Oct 2012 19:18
I noticed something new regarding this problem, I started working on my crafting menu, and when I finaly got the buttons working, I started spamming the menu, and then going back again. When I was doing that, after the 4th or 5th time, textures started disapearing. Sprites turned white. The thing this time though, is that I don't delete any sprites, I just hide them. It's not the same thing as with the delete sprite options, but it's similar
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 25th Oct 2012 02:01
If you load too many images and overflow GPU memory then subsequent images may overwrite old ones or fail to load their pixels.
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 25th Oct 2012 10:38 Edited at: 25th Oct 2012 10:40
The thing is that i dont load more spritrs, apart from the 5 I use in the crafting menu. Now that I think about it, I dont even modify any of the world sprites, I just move the camera and hide the GUI. Regardless, I will probably have to rewrite a the spritesystem, 15k sprites at a time causes a lot of proplems
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 25th Oct 2012 16:09
Quote: " "As a workaround for now perhaps using GetManagedSpriteCount() as the number of sprites loaded may work?"
That may help in some way..."


I only meant regarding the ever increasing for n loop you mentioned. Instead of using for n=1 to 50000 etc, have you tried for n= 1 to getmanagedspritecount()?

I doubt it will make any difference if it is a memory problem but wouldn't take long to test. As you say 15k of sprites is a lot, if you mean 15000 sprites. I cannot see why you would need that many at once. Perhaps reducing it to a more manageable amount may be your best option.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Oct 2012 16:24
DVader, unless GetManageSpriteCount() returns the highes sprite id, it won't do the job. If it only returns the number of sprites, then the loop won't get sprite ids that are automatically created, they start at 10000.

Cheers,
Ancient Lady
AGK Community Tester
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 25th Oct 2012 16:44 Edited at: 26th Oct 2012 00:35
The reason im using 15k sprites is because im lazy. Basicaly I have a world that is 100x100 tiles, which all have a sprite each, then there are things on top (like plants) which are on about every second tile.

Though only about 10x7 are actually seen. I should probably make it more efficent since both loadingtimes and FPS isn't the best on android.

EDIT So I decided that I would make the change, and I thought it would be realy hard and take forever, turns out it took 1 hour or so and inproved performance by a bunch. The only problem is that the sprites still get deleted. The sprites I clone get deleted, and the images for my world also get deleted... And it happens "one crafting menu" earlier

Edit 2 Wow, every time I find something out about this the problem starts getting weirder. Basicaly I started looking for what caused the problem. I found it was a subroutine which removed the mediea that I use in the menu. I decided I would make a new subroutine to do the same thing but only in the crafting menu that was causing the problem.

But when I changed the function, the problem still existed. The function basicaly did 2 things, remove sprites and images that had to do with buttons, and removing sprites and images that where used in the menu just not as buttons. I found that it was the part that removed general media that caused problem. So I went looking for what media caused the problem. After a bit of research, I found that the problem was a text object. Which the subroutine that crashed it didn't have anything to do, apart from that it had the same variable storing it's ID. And removing it solved the problem

Now that I think about it, the problem was that I check if a sprite with the ID exists. And since the text has a low ID, one such sprite exists, the sprite I use to clone to render the world. And on top of that, I also deleted the image used, making the sprites already in existense disappear to. Though, right now im just happy I solved the bug.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 26th Oct 2012 18:32
Glad you fixed it. I imagine your fps has gone up significantly if you are only using the sprites needed to fill the screen with a slight overlap for the edges. I wonder why you have to delete the sprites at all? I would hide them when they are not needed and show them when the game is run, if it didn't affect performance of course. I only delete sprites when it impacts the games speed.

The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 26th Oct 2012 18:38
It did increase the FPS, my android tablet increased from 30 to 60, my phone got a decrease yesterday, but an increase today... im not sure what happned. My utrabook got some weird glitches but I fixed them by using the acurate mode on SetSyncRate.

Login to post a reply

Server time is: 2024-04-28 17:38:12
Your offset time is: 2024-04-28 17:38:12