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 / Sprites in the same array help

Author
Message
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 5th Dec 2022 09:03 Edited at: 5th Dec 2022 09:10
So I am creating Two different types of sprites from the same array.

They do not effect each other at all, but when I use them against another array then they have a effect.

So I have one array, backgrounds, and bombs.

If i use the bombs on a different array to explode them, it works.

But when I want to effect the background sprites in the same array nothing happens.

I have also come across this error when trying to delete my sprites in the array.

Only the first sprites in the array will delete, and then the other sprites type are ignored.

Am I missing something?

Edit>

I am adding them all in the array like from there different types

backgrounds.insert(Frames)
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 5th Dec 2022 10:55 Edited at: 5th Dec 2022 10:56
Quote: "I have also come across this error when trying to delete my sprites in the array.

Only the first sprites in the array will delete, and then the other sprites type are ignored."


work from the end of the array to the start



when you remove items from an array it changes the size of the array and invalidates any indices in the loop, always work from last to first when removing items
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 5th Dec 2022 11:15
PartTimeCoder

That makes good sense, I will remember this.

I just created a different array for them all to work together.

Thanks

Login to post a reply

Server time is: 2024-04-25 18:06:54
Your offset time is: 2024-04-25 18:06:54