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 / Deletion with arrays

Author
Message
Kozax
8
Years of Service
User Offline
Joined: 28th Jul 2015
Location: London, UK
Posted: 4th Sep 2015 19:34 Edited at: 4th Sep 2015 19:35
Hello,

I have created an array to create boxes per x seconds.
I want to delete the boxes with two conditions.
One after the tween ends and another if the circle(player) touches them.



If I touch the Box it works but if I let the box disappear it shows the error Index:0, Array Length: <Empty> in main.agc at line 209.
Line 209 is : If GetSpriteCollision(Boxes[m], Circle) = 1

Can anyone help?
Hockeykid
DBPro Tool Maker
16
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 4th Sep 2015 20:09 Edited at: 4th Sep 2015 20:10
You are deleting the box from the array when it fades out, but then the "GetSpriteCollision()" command is called and it is attempting to get the value for "Boxes[m]" which has already been removed.

This should work:



Also, you probably should be calling "PlayTweenSprite" every loop. Just call it once to start the tween and it should update itself.



Sean

Kozax
8
Years of Service
User Offline
Joined: 28th Jul 2015
Location: London, UK
Posted: 4th Sep 2015 20:27
Thank you very much! It works !

Login to post a reply

Server time is: 2024-05-23 01:22:00
Your offset time is: 2024-05-23 01:22:00