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] Error in collision sprite

Author
Message
Humildadever
13
Years of Service
User Offline
Joined: 17th Aug 2010
Location:
Posted: 21st Feb 2021 12:48


//Colisao
If GetSpriteCollision (myscene_my_snowman,myscene_sprite61)=1
deletesprite (myscene_sprite61)
//score=score+1
endif


Gives the error: Sprite 100054 dos not exist in main.agc at line 167



I try many things but akways the same error

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

Go to answer

n00bstar
20
Years of Service
User Offline
Joined: 9th Feb 2004
Location: Montreal, Canada.
Posted: 21st Feb 2021 13:44
I'm guessing that line 167 is your If GetSpriteCollision line and that your first collision returns true, then deletes the sprite. Next time you cycle through and get to line 167, there is no more sprite61 so your code fails because the sprite doesn't exist any more.
-----------------------------------------------------------------------------
We all got a chicken duck woman thing waiting for us
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 21st Feb 2021 13:45 Edited at: 21st Feb 2021 13:47
This post has been marked by the post author as the answer.
assuming that piece of code is within a loop. ie:


once there is a collision, the next time through will produce the error where myscene_sprite61 was deleted/no longer exists.
to protect against that, only check for collision with myscene_sprite61 if it exists. IE:


hope that helps
[My Itch.io Home] [Now Playing]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]

Login to post a reply

Server time is: 2024-04-20 12:11:31
Your offset time is: 2024-04-20 12:11:31