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.

2D All the way! / problem deleting sprites can anyone help :,(

Author
Message
The Core
20
Years of Service
User Offline
Joined: 1st Aug 2005
Location: mother ship
Posted: 15th Feb 2006 17:15
ok i need help i have made the following

1. player with control ( there all sprites)
2. enemy a.i
3. a bullet that when it hits the a.i it hides it.

but i would like to not just hide the enemy a.i i would like to delete it. The only problem is everytime i chance my

if sprite collision (8,7) then hide sprite 7

to
if sprite collision (8,7) then delete sprite 7

the sprite just flash's then reapear's because the sprites are made within the main loop. ( so its deleting the sprite then remaking)

but i cannot take the sprites out of the loop because they dont move then it says ( sprite do's not exist at line 319 ) which is the if sprite collision line, all the enemy movement commands are within the loop.

can anyone lend me a hand without getting to tech as i'm stupid and easyly confused. thanx ok here is my code



and here is a pic of my game so far

plz help

i'm E.T i have so much tech but yet i dont have a mobile phone! where is a land line when you need one
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 15th Feb 2006 22:11
Why do you want to delete them?... anyway, theres a command that checks if a sprite exists, so you could check if the sprite exists before performing actions on it within the loop. By this i mean that you shoul firstly create each sprite before entering the loop, then whithin the loop, do something like...


something like that. However, you should have a look at functions and that stuff, because it will save you from :
1- rewriting the same code millions of times
2- avoid probable mistakes
3- easier to understand the use of something

and so on....
The Core
20
Years of Service
User Offline
Joined: 1st Aug 2005
Location: mother ship
Posted: 15th Feb 2006 22:45 Edited at: 15th Feb 2006 22:47
just tryed it got tha same comment as before error sprite do's not exist at line 340 thats this line

if sprite collision (8,7) then delete sprite 7

and if i just keep the sprite hidden it still follows my player but invisible tryed it just by testing with

if sprite collision (8,7)then print "enemy death"
even tho there is no sprite the collision keeps printing it

i'm E.T i have so much tech but yet i dont have a mobile phone! where is a land line when you need one
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 15th Feb 2006 23:17
That is becuase you must also perform an if sprite exists statement with that part, so as...



i'd avoid mixing those two if statements in 1 because it may also jump to an error...
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Feb 2006 15:52
Quote: "i'd avoid mixing those two if statements in 1 because it may also jump to an error... "


Indeed it would. A tidier way would be like this:




The Core
20
Years of Service
User Offline
Joined: 1st Aug 2005
Location: mother ship
Posted: 17th Feb 2006 16:36
thanx

i'm E.T i have so much tech but yet i dont have a mobile phone! where is a land line when you need one

Login to post a reply

Server time is: 2026-06-12 23:24:53
Your offset time is: 2026-06-12 23:24:53