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.

Newcomers DBPro Corner / why am i geting sprite does not exist error

Author
Message
vman187
4
Years of Service
User Offline
Joined: 21st Jan 2015
Location:
Posted: 28th Sep 2015 04:28
I am trying to make a game menu using sprites what i was doing using
a spite as a cursor when i click on a sprite i am trying to clear the hole screen so i can load the next screen i get the error when i click on the same sprite i am deleting

here is my code maybe someone can figure out what i am doing wrong
rem this loads bacground image
load image "\media\gamemenu.jpg",1
sprite 1,0,0,1

rem this loads images for the image buttons
load image "\media\menu.JPG",2
sprite 2,75,50,2
load image "\media\new game.JPG",3
sprite 3,75,200,3
load image "\media\exit game.JPG",4
sprite 4,75,300,4

rem cursor
load image "\media\cursor.dds",5


do
sprite 5,mousex(),mousey(),5

if mouseclick()=1 and sprite collision(5,3)>0 then delete sprite 3

sync
LOOP
WickedX
10
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Sep 2015 17:12
In your do/loop you check for collision with sprite 3 and 5. Once you delete sprite 3 you continue the collision test. Since sprite 3 no longer exists you receive the error.
vman187
4
Years of Service
User Offline
Joined: 21st Jan 2015
Location:
Posted: 29th Sep 2015 18:02
i was stuck on this for 3 days and i got it to work by doing this i don't know if it is the right way but it works


load image "\media\gamemenu.jpg",1
sprite 1,0,0,1

rem this loads images for the image buttons
load image "\media\menu.JPG",2
sprite 2,75,50,2
load image "\media\new game.JPG",3
sprite 3,75,200,3
load image "\media\exit game.JPG",4
sprite 4,75,300,4

rem cursor
load image "\media\cursor.dds",5


do
sprite 5,mousex(),mousey(),5




if sprite exist(3) then gosub clearscreen
if sprite exist(4) then gosub endgame




sync
LOOP




clearscreen:
if mouseclick()=1 and sprite collision(5,3)>0
delete sprite 1
delete sprite 2
delete sprite 3
delete sprite 4
delete image 1
delete image 2
delete image 3
delete image 4
endif

return

endgame:
if mouseclick()=1 and sprite collision (5,4)>0 then end

return
WickedX
10
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Sep 2015 18:46
Attached is a old game project of mine, I think will help. What do you think about using something like this.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2019-04-24 01:47:40
Your offset time is: 2019-04-24 01:47:40