Slick Forums

Discuss the Slick 2D Library
It is currently Mon Oct 15, 2018 2:32 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Oct 01, 2013 8:06 pm 
Offline

Joined: Fri Sep 27, 2013 7:46 pm
Posts: 7
Hi,

I'm coding a Map Editor for my TD game and I'm experiencing a little issue with my cells rendering.
I want these cells get a special border (currently a red one) when it got focused, so I try first to had a white border using TWL theming.
I already displayed cell background (possibly multi-layered) from a Slick Image (from a SpriteSheet), it's rendering fine and I created a gridcell theme that is rendering fine too.
But when I use it together, it's rendering wrong.

This is my painting code for cells, inheriting indirectly from Widget (it's very simple) :
Code:
   @Override
   public void paintWidget(GUI gui) {
      for( Image l : layers ) {// Currently there is only one layer.
         l.draw(getX(), getY());
      }
   }


I surely made a newbie mistake but I'm unable to find it alone (or understand it).

Thank you in advance for your precious help.

EDIT:
I tried without base theme reference, it's the same result and I tried without the overlay in the theme, this is rendering only the layers (as expected) without any issue (but without the grid).


Attachments:
File comment: All rendering cases with grid overlay and layer images.
scr_2dgame_IssueOverlay.jpg
scr_2dgame_IssueOverlay.jpg [ 198.86 KiB | Viewed 4756 times ]
File comment: The TWL Theme in use
defaultTheme.zip [136.49 KiB]
Downloaded 222 times
Top
 Profile  
 
PostPosted: Tue Oct 01, 2013 8:16 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
Do you call slick render methods from within TWL? If that is the case you need to pause rendering before calling slick code and resume rendering after. These methods can be found in the LWJGLRenderer class - use GUI.getRenderer() and cast the result.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Wed Oct 02, 2013 5:07 pm 
Offline

Joined: Fri Sep 27, 2013 7:46 pm
Posts: 7
Thank you for your answer.

Image is a Slick Object here, so draw() is too.
I wish to use only one engine for my application but Slick has better Image and Sprite system and TWL is... TWL (a Themable Widget Library)...

I tried:
Code:
   @Override
    public void paintWidget(GUI gui) {
      LWJGLRenderer renderer = (LWJGLRenderer) gui.getRenderer();
      renderer.pauseRendering();
      for( Image l : layers ) {
         l.draw(getX(), getY());
      }
      renderer.resumeRendering();
   }

This is working fine !


Top
 Profile  
 
PostPosted: Wed Oct 02, 2013 8:23 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
You can do the same with TWL - the preferred way to get an TWL Image object is by overriding the applyTheme method and retrieve it from the ThemeInfo. But you can also construct them by calling into the Renderer (Texture -> Image).

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Sat Oct 05, 2013 6:23 am 
Offline

Joined: Fri Sep 27, 2013 7:46 pm
Posts: 7
Surely but I have too much trouble with TWL for now and it's enough abstracted to be changed later.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group