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.

Dark GDK / Clip sprite to region

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Sep 2012 15:37
Hey all,

I've been working on a 2D level editor for my game, and I've encountered a problem when making the background sprite. It needs to scroll, so it's much bigger than the actual viewport and therefore ends up covering up parts of the GUI. Most of the GUI is drawn before the actual editor, as the editor itself is just a sub-panel of the GUI and drawn last.

So I need to clip the background sprite to the viewport. I've found the command dbSetSpriteTextureCoordinates() but I haven't been able to figure out how to make it work for this.

Has anyone got any ideas?

Thanks

"everyone forgets a semi-colon sometimes." - Phaelax
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Sep 2012 04:29
Set the sprite size to the size of the visible part of the sprite, and set the UV coordinates to the fraction of the total sprite which is visible.

For example, if the bottom half of the sprite is to be hidden, set the sprite size so that the width is unchanged but the height is 1/2 what is normally is. Then set the V component of the UV coordinates of the bottom left and bottom right corners to 1/2.

[b]
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Sep 2012 05:13
Thanks Diggsey, that worked.

"everyone forgets a semi-colon sometimes." - Phaelax

Login to post a reply

Server time is: 2024-11-18 21:32:27
Your offset time is: 2024-11-18 21:32:27