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 Studio Chat / [SOLVED] Make endless amount of sprites

Author
Message
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 1st Oct 2021 03:04
I'm a little confused

How can I make a endless amount of sprites for my coins?

So in game when you collect a coin another coin is displayed on screen to show you collected a sprite.

but I'm using the same sprite number each time so I can delete that sprite.

when I make endless sprites they don't delete.

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

Go to answer

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 1st Oct 2021 12:59 Edited at: 1st Oct 2021 12:59
Sometimes we need Alan Turin to decipher your threads, Enigma, Meh!, we got GGH!

I would not delete the sprite just set it invisible and reuse it, delete and create have overhead, SetVisible has far less

You're level only contains a single coin at any one time ?
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 1st Oct 2021 13:18
You can have up to (although not recommended you have them visible at once) 4.1 Billion Sprites...
So instead of trying to do everything with 1 Sprite., maybe have 1 for the UI and an array of them for "In-Game" .. I mean most Mobile Devices can handle about 250-500., while a Desktop / Laptop can handle 2-5,000.
In fact generally AppGameKit Script is likely to limit what you can show based on updates you need to make more than the Graphics Hardware.

Look at the examples to see how to handle Multiple Sprites, that's what they're there for.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Oct 2021 02:13
How many coins can be displayed on screen at once in your game? That's the maximum number of sprites you'd need to create for coins. Well, technically 1 sprite with a bunch of clones. Don't delete them, hide them.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 2nd Oct 2021 06:30


PartTimeCoder

That's true, never thought of it that way. But sometimes I have coins lined up in front of each other. think of super Mario brothers. it just looks cool when you get a bunch of coins flying up in the air.

Raven

I was thinking about a array but there still empty sprite numbers. I think after the array they all will be added to the delete list?

Phaelax

I agree, I will try to set up a array and make around 10 coin sprites and hide them. I like that idea.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 2nd Oct 2021 07:51 Edited at: 2nd Oct 2021 08:10
This post has been marked by the post author as the answer.
generate all the coins you want, wherever you want, and store their IDs in an array.

when they're collected, do whatever you want with them. make them explode, fly up, whatever, and, remove them from the array of active coins.

so, if you want 10 coins to start with:


then, in your game loop



yah, since i'm re-spawning the coins, i wouldn't need to delete them only to recreate them somewhere else but i don't expect you really mean "endless"?
[My Itch.io Home] [AGK on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 2nd Oct 2021 16:32


Virtual Nomad

Well that is half of what I needed and then you said after I collect them I don't have to delete them till after I make them fly al over. and that was a great idea

So after I made a array and after I collect them and after they fly then I am deleting them.

It works good and looks good.





Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 2nd Oct 2021 17:31
well, i guess you really did mean "endless".

this is probably criminal in all countries throughout the world:

watch the memory jump when "1" is pressed:

...more than 40mb just for telling it to reserve space for 500,000 coins when you would never have 500,000 coins in view or near your player.

VN wrote: "generate all the coins you want"

i hereby retract that statement
[My Itch.io Home] [AGK on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 2nd Oct 2021 17:48
Well lol, I changed that real fast to my coins count. I have 20 coins at a time but my coins sprite number starts at 600.
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 2nd Oct 2021 18:10


I would not use so many sprites if I new how to position my background images as I move, I still don't understand how I can do this.

I tried using only three sprites then reposition them as I move but there never in the right place, so I end up making 200 different sprites for the background.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 2nd Oct 2021 18:43
Quote: "I would not use so many sprites if I new how to position my background images as I move, I still don't understand how I can do this."


Move the view See: "SetViewOffset"


Quote: "dim coins_t [ 500000 ] as coin_t"


My CPU cried!!


Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Oct 2021 02:17
I know this was already marked as solved, but wanted to share my example.

Use the left mouse button to trigger an explosion of coins. MAX_TRIGGER determines how many coins will be used in each triggered explosion. As you click, it'll set the next batch of available coins. When the explosion is over, those coins are released back into the pool to be reused again. You can click all day long repeatedly and have coins constantly flying about, but never use more than 50 sprites.


Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 6th Oct 2021 06:43
Phaelax

Thank you for the good example.

I will play with it and see what I can do with in,.

Login to post a reply

Server time is: 2024-04-18 06:39:43
Your offset time is: 2024-04-18 06:39:43