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 / Sprite Priority issue

Author
Message
nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 11th Oct 2009 20:47
I have a lot of issues I know... Now it's about the sprite priority in my game. Here is the problem: I want my game to show my sprites in a specific order. For this, I have set the sprite priority for my sprites, with no effect. The player is supposed to be drawn above the background but below the shading of the scene. My code look like this:



As you can see, the background have a priority of 1, ground 2, player 3, and shading 4. But! Whenever I start the game, the player is drawn below every sprite, which is totally not what I want.

Please help me out, it'll be very much appreciated!

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Oct 2009 21:17 Edited at: 11th Oct 2009 21:19
The way sprites are drawn naturally in the newest update without the SPRITE PRIORITY command is by the image number used on the sprite. So if you want the player to be above all other sprites load the player image as the highest image number.

Here's an example:


The above code snip randomly picks sprite numbers (1 to 999) and image numbers (1 to 17). The number on the top of each box is the sprite number and the number at the bottom of each sprite is the image number. Press the spacebar to pick a new image number for the mouse sprite. If the sprite at the mouse is image number 10 it's above all the sprites that use image numbers 1 to 10 and behind sprites that use images 11 to 17.

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Oct 2009 21:28
in function placeplayer(px, py)

try:


instead of:



nackidno
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Där solen aldrig skiner
Posted: 11th Oct 2009 21:29 Edited at: 11th Oct 2009 21:30
Thanks, that explain the thing for me. I also noticed that when I changed PASTE SPRITE for the player to SPRITE It works perfectly.

Nomad, posted at same time. ^^ That was part of the problem and it's fixed now. Thanks.

Login to post a reply

Server time is: 2024-09-28 10:32:47
Your offset time is: 2024-09-28 10:32:47