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.

AppGameKit Classic Chat / Issues with text vs sprite depth

Author
Message
Satchmo
19
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 9th Jan 2016 20:50 Edited at: 9th Jan 2016 20:51
Hey Guys,

Is there any particular way to get text to appear behind sprites? It seems like the set text depth command is not actually having any effect. With a sprite depth of 1000 and a text depth of 5000 the text still appears in front of the sprite. Note that I am using the draw sprite command, not sure if this affects anything or not.

Thanks
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 11th Jan 2016 16:14
The depth value is used by the rendering engine to sort sprites and text into the correct order for drawing, it doesn't use a depth buffer for 2D, which would enable drawing in any order. By using DrawSprite and then calling Sync the rendering engine would draw the text over the sprite (and possibly draw the sprite again unless you have made it invisible before calling Sync). To draw the sprite after everything else you can split Sync into its component parts Update, Render, Swap, and placing your call to DrawSprite in between, like so
dooz
19
Years of Service
User Offline
Joined: 22nd Sep 2005
Location:
Posted: 12th Jan 2016 03:15
Quote: "The depth value is used by the rendering engine to sort sprites and text into the correct order for drawing, it doesn't use a depth buffer for 2D, which would enable drawing in any order. "


If this is the case, why have a "SetText/SpriteDepth" function? I'm having the same trouble with text over sprites, etc.

This function should force the rendering engine to draw in the specified "Depth" as per calls to the function. If you don't call it, then they should be rendered in order of creation, with latest on top, or as specified by other function, e.g. Set...Transparency, etc.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Jan 2016 07:28
Quote: "If this is the case, why have a "SetText/SpriteDepth" function? I'm having the same trouble with text over sprites, etc."


Because if you simply Sync(), then they are drawn in the specified depth order.
Satchmo is using DrawSprite(), so these are drawn first, followed by everything else during the Sync() afterwards.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 12th Jan 2016 13:47
Just let AppGameKit do the drawing and save yourself the trouble

Unless you have an effect that requires this.
dooz
19
Years of Service
User Offline
Joined: 22nd Sep 2005
Location:
Posted: 12th Jan 2016 20:54
DOH! Misread!! I thought it said "The depth value is NOT used by the rendering engine ..."

Thanks folks!

Login to post a reply

Server time is: 2024-11-17 03:02:18
Your offset time is: 2024-11-17 03:02:18