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 / Deleting sprites problem (DBC)

Author
Message
ManiacBR
18
Years of Service
User Offline
Joined: 26th Oct 2006
Location:
Posted: 14th Nov 2006 11:51
Ok this i'm probably being really stupid, but when I fire my bullet across the screen and it hits the enemy I can't get the sprites to delete off the screen.



This does nothing as the bullet(4) and enemy (2) just carry on across the screen.

someone help please!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 14th Nov 2006 12:18
if deleting them is slow, just hide and move off screen away from any distance checks or possible collision weirdness. bullets are usually re used lots so delete them at the end and hide them during gameplay.

ManiacBR
18
Years of Service
User Offline
Joined: 26th Oct 2006
Location:
Posted: 14th Nov 2006 15:34
[/quote]if deleting them is slow, just hide and move off screen away from any distance checks or possible collision weirdness. bullets are usually re used lots so delete them at the end and hide them during gameplay.[quote]

I've tried doing this but it still doesn't work. Here's part of my bullet code,



This should move the sprite off the screen, but all that happens is that it gets stuck and stays at the point x = 580.

I can't figure this out.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Nov 2006 18:53
I don't know what your loop looks like but x may never be reaching 580. Or, your loop may be waiting for x to become 580 and stop before your conditional has a chance to be tested. In which case, x is 580, but the loop stopped before your test.

Like indi wrote, you can remove them from the viewable area, hide them, and delete them after your other updates. Here's an example based on my supposition that your test for x >= 580 is being skipped.



Enjoy your day.
H4ck1d
18
Years of Service
User Offline
Joined: 27th Dec 2005
Location: Yes
Posted: 14th Nov 2006 19:17
And make sure your bullet_x variable is being update, too, to return the sprite's current x

-H4ck1d

Login to post a reply

Server time is: 2024-11-26 08:58:44
Your offset time is: 2024-11-26 08:58:44