Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  How to draw in a section of the screen  (Read 339 times)
0 Members and 1 Guest are viewing this topic.
Offline CTucker1327
« Posted 2013-12-10 04:23:50 »

So, here's my little game frame thingy.



Basically, Where the purple/pink is, is where I want to draw my actual game.

I'm using LibGDX and I'm going to be used a TiledMap for this, but I'm not sure how to only make it draw in that section of the screen.

Any ideas? I already have the bounds for the box.

   // X 150 -> 1000
   // Y 720 -> 180


Just not sure on how to go about creating that area to draw in.
Offline Longarmx
« Reply #1 - Posted 2013-12-10 05:12:51 »

Make a new camera with viewport and position where you want it to be.
1  
2  
3  
OrthographicCamera camera = new OrthographicCamera(850,560);
camera.setPosition(150,180);
camera.update();

Render everything you want in the purple area after you call
1  
batch.setProjectionMatrix(camera.combined);

I don't know if you have to flush or end the batch for this to work or if you can call it while it's drawing.

Also, all is this is an untested idea I had while reading your problem.

Offline CTucker1327
« Reply #2 - Posted 2013-12-10 05:14:29 »

Make a new camera with viewport and position where you want it to be.
1  
2  
3  
OrthographicCamera camera = new OrthographicCamera(850,560);
camera.setPosition(150,180);
camera.update();

Render everything you want in the purple area after you call
1  
batch.setProjectionMatrix(camera.combined);

I don't know if you have to flush or end the batch for this to work or if you can call it while it's drawing.

Also, all is this is an untested idea I had while reading your problem.

Thanks, all I was missing was the set Position code.

EDIT: Got home, there's no way to set the position of the camera
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline samurapizza

Innocent Bystander





« Reply #3 - Posted 2013-12-10 05:29:08 »

just commenting to save. love all these small fixes.
Offline CTucker1327
« Reply #4 - Posted 2013-12-10 09:17:35 »

The solution given didn't work and I'm still unable to figure this out.
Offline Longarmx
« Reply #5 - Posted 2013-12-11 00:41:08 »

What do you mean by doesnt work. Is it drawing correctly but in the wrong spot? Is it even drawing at all? In any case, you can always draw everything with a 150,180 offset

Edit:
Sorry, I forgot that you have to set the position vector directly. Use this instead to set the position.
1  
camera.position.set(x,y);

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.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!