Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (578)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Solved][LibGDX] ShapeRenderer  (Read 481 times)
0 Members and 1 Guest are viewing this topic.
Offline bilznatch

Senior Duke


Medals: 8
Projects: 2
Exp: 1 year


I'm bad, I'm bad, I'm really... really bad T_T


« Posted 2013-11-22 23:57:57 »

In my code, I use the the ShapeRenderer to draw some basic rectangles after my batch drawing. (Not inside of course)

The code looks like:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
       shapeDrawer.setProjectionMatrix(camera.combined);
     
       shapeDrawer.begin(ShapeType.Rectangle);
       shapeDrawer.setColor(0.8f, 0.8f, 0, 1);
       shapeDrawer.rect(playerRect.x - 200, playerRect.y - 355, 500, 6);
       shapeDrawer.end();
       
       shapeDrawer.begin(ShapeType.FilledRectangle);
       shapeDrawer.setColor(1, 1, 0, 1);
       shapeDrawer.filledRect(playerRect.x - 200, playerRect.y - 355, 500 / neededXP * playerXP, 6);
       shapeDrawer.end();


The problem is that whenever my player moves, this bar sort of stutters behind by a pixel or two, whereas every other element that's drawn in the initial batch is in sync with the player.
Is this because things within the batch calls are all rendered simultaneously, and that the shaperenderer is going later, or is it because of something I'm doing?

A side note: If I zoom the camera out even a little bit this stops, I haven't tested a different starting camera zoom though.
Offline Nate

JGO Kernel


Medals: 153
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2013-11-23 16:31:56 »

Note you are using an old version of libgdx.

Try adjusting toward pixel centers.
1  
shapeRenderer.translate(0.375f, 0.375f, 0);

Offline bilznatch

Senior Duke


Medals: 8
Projects: 2
Exp: 1 year


I'm bad, I'm bad, I'm really... really bad T_T


« Reply #2 - Posted 2013-11-23 18:14:46 »

Of course I am... God dang it. Thank you for that Nate.
I'll try your fix as well and see if that helps.
EDIT: Yup that fixed it!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

DarkCart (24 views)
2014-10-31 21:44:48

DarkCart (30 views)
2014-10-31 21:43:57

TehJavaDev (40 views)
2014-10-27 03:28:38

TehJavaDev (31 views)
2014-10-27 03:27:51

DarkCart (45 views)
2014-10-26 19:37:11

Luminem (27 views)
2014-10-26 10:17:50

Luminem (31 views)
2014-10-26 10:14:04

theagentd (36 views)
2014-10-25 15:46:29

Longarmx (64 views)
2014-10-17 03:59:02

Norakomi (62 views)
2014-10-16 15:22:06
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!