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! / layering sprites

Author
Message
zDough BoyZ
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 18th Jul 2007 07:53
how would you layer sprites so that it would go background---->hud---->players/enemies/lasers
because when i try to load my background image i cant see anything else.

The Internet Is TUBES
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 18th Jul 2007 09:14
If you're manually drawing the scene (Drawing each Image/Sprite Manually), then you'd draw the Backdrop -> Characters -> Hud. This work OK in a lot of 2d game situations, but not all.

If you need to manage the draw order dynamically then you've a few options.

A) Use Sprite Priority to control the Z of sprite in Dbpro. Watch the range of the Z values though. Dbpro used to choke if you set the depth too high. but might have been fixed.

B) You can process the scene to the screen manually. That is, you work out what characters are within the viewport (the screen) then once you have a list of visible characters, you sort those into order. Once the list of characters is sorted, you can run through and draw them from Back (far object) to front (nearest object).

C) You can dynamically create/destroy sprites each frame. For this approach you'd need your own data structures (typed array for example) to store the information about your characters/objects in the game world. To draw, this is much like option B, but allow DBpro to draw sprites in batch is generally the faster option in terms of direct 3D. (less draw calls) - Of course the relies upon how efficiently you can create/destroy them.

In PlayBasic you'd control depth view using either sprites depth of camera depth.

zDough BoyZ
16
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 18th Jul 2007 10:02
ok i think what im trying to do is the option "B". i have three images right now. how would i arrange them from "back" to "front". do i label each sprite individually(if so how) or just arrange them from how the code is written.

The Internet Is TUBES
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Aug 2007 18:03 Edited at: 1st Aug 2007 18:04
If you are using DBC, you can't use SET SPRITE PRIORITY but you can use PASTE SPRITE and that is the best way to do it in DBC
If you are making a 2D game where the higher up a sprite is on the screen the further back it should be in priority, write something like this.



I haven't tried this so it might not be the best way, but it should work
If you have DBP then ignore this as SET SPRITE PRIORITY is much easier.

Your sig was erased by a mod because it's larger than 600x120
I didn't know about that rule and it was 659 x 126!
Isn't that a little OTT? I'm gonna have to re-make it because of 65 pixels!!!

Login to post a reply

Server time is: 2024-05-19 05:07:43
Your offset time is: 2024-05-19 05:07:43