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.

Dark Physics & Dark A.I. & Dark Dynamix / How do you avoid-object already exists (with cars)

Author
Message
leigh4ever36
13
Years of Service
User Offline
Joined: 29th Dec 2010
Location: united kingdom
Posted: 7th Mar 2011 21:15
Hello I hope I can take a moment of everyones time, what Ive got at the moment is just an example of 2 cars falling down.

The car1 loads and When you press the right key it changes to car2 falling down. But I press left to switch back to car1, I get object already exists.

I dont know if I need to somehow delete a vehicle to make way for another vehicle, And I am abit stuck on what commands to put down to solve it

I know the codes not pretty but here it is


and thankyou for your time
BillR
21
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 8th Mar 2011 06:24 Edited at: 8th Mar 2011 07:08
The error is because you are loading the same objects again with the same object numbers
Only load each object once, and just switch which object is being used
You need to set up your program differently and have all your subroutines and functions come AFTER your main loop


Try this code...but change the 4 load lines first!

LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 12th Mar 2011 15:26
What I do to avoid duplicating objects is to create a global variable,
and then create a function
.

Then I call the function in the code when I need another object number, like this:


This way, objects are never duplicated. You can also do the same with images or sprites.

Login to post a reply

Server time is: 2024-03-28 13:08:12
Your offset time is: 2024-03-28 13:08:12