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 / delete object in if statement

Author
Message
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 16th Mar 2008 21:41
hi all!

hope you're well,
another quick one,

im having trouble deleting an object when im in an if statment, ex:

do

`main game code!!

if object collision (a,b)
delete object b
print "object b was deleted, this if statement shouldnt be active again"
endif

loop


-for some reason it wont let me, it errors out with cannot delete object.

now im not stupid - i realise thats because im within the loop, and the fact that its looping around and calling itself again too quickly..

whats the solution for this? just hide the object and delete it later?

thanks

Paul
Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 16th Mar 2008 22:08
The problem is that after deleting the object you can not delte it again because it is not there, also the program will crash if you try to chack for collision on an object that is not there. Try:
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 17th Mar 2008 00:06
Just pointing out that Jerok forgat an endif there;


"I kören hörs de brummande busarna Björnligan och Gondolen"
Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 17th Mar 2008 01:10
Ah tyvm. I feel dumb.
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 18th Mar 2008 10:02
doh , cheers, i did try a few different if statements before the delete code but never before the if collision bit..

i was just assuming it would know the obj didnt exist and wouldn run the if statement - i think i ASS-U-ME too much !

cheers!

Paul

Login to post a reply

Server time is: 2024-09-27 12:18:29
Your offset time is: 2024-09-27 12:18:29