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 / [SOLVED] Get all the sprites ids that exist in to an array

Author
Message
brunuu
6
Years of Service
User Offline
Joined: 4th Jun 2018
Location:
Posted: 9th Jul 2019 02:23 Edited at: 9th Jul 2019 02:29
Is it possible to get all the ids that exist? in a quick way



I tried something like this, but this is pure brute force
and can be slow

The author of this post has marked a post as an answer.

Go to answer

Increase
7
Years of Service
User Offline
Joined: 21st Feb 2017
Location:
Posted: 9th Jul 2019 02:35
sprites as integer []

for x = 1 to 100000 : If getspriteexists(x+100000) = 1 then sprites.insert(x+100000) : next x

This is because sprites start at index 100000 - and - as far as i know are limited to 100000 , sprites should exist from 100000 to 200000.


Another method is to store all spritesin an array from the beginning :

sprites as integer []

Function Create_Sprite (sprites ref as integer)
sprite = CreateSprite(0) : sprites.insert(sprite)
Endfunction sprite


which could be called like

monster = Create_Sprite (sprites)
brunuu
6
Years of Service
User Offline
Joined: 4th Jun 2018
Location:
Posted: 9th Jul 2019 02:55
I have manually assigned the ids, but creating an array and inserting whenever something is created seems to work fine, I'll go with it. I'm going to have to change some things but it's a good solution
Qugurun
Valued Member
9
Years of Service
User Offline
Joined: 8th Dec 2014
Playing: AppGameKit
Posted: 9th Jul 2019 12:39 Edited at: 9th Jul 2019 12:44
This post has been marked by the post author as the answer.
I have prepared for you an example of how this can work.



https://www.instagram.com/qugurun/

Attachments

Login to view attachments
brunuu
6
Years of Service
User Offline
Joined: 4th Jun 2018
Location:
Posted: 9th Jul 2019 14:49
Yes, I did something similar like that.

But it's a pity that there is not an immediate command that returns all existing ids of sprites to an array

Login to post a reply

Server time is: 2024-11-22 21:44:47
Your offset time is: 2024-11-22 21:44:47