Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  LibDGX graphic mechanism  (Read 432 times)
0 Members and 1 Guest are viewing this topic.
Offline Kongo

Junior Newbie





« Posted 2014-07-09 07:39:20 »

Hello,
I am trying to get view in my game like this:

Should i use perspective camera or it is possible to do it with orthographic camera? Do you have any idea how to do that?
My idea was to do it in this way
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
Texture texture;
   OrthographicCamera cam;
   SpriteBatch batch;  
   final Sprite[][] sprites = new Sprite[10][10];
   final Matrix4 matrix = new Matrix4();
   final Matrix4 matrix2 = new Matrix4();
   
   Sprite bucket;

   public GameScreen(final SSS game) {
      this.game = game;

      texture = new Texture(Gdx.files.internal("assets/badlogic.jpg"));
      cam = new OrthographicCamera(10, 10 * (Gdx.graphics.getHeight() / (float)Gdx.graphics.getWidth()));        
      cam.position.set(5, 5, 10);
      cam.direction.set(-2, -2, 0);
      cam.near = 1;
      cam.far = 100;      
      matrix.setToRotation(new Vector3(1, 0, 0), 90);
 
      for(int z = 0; z < 10; z++) {
         for(int x = 0; x < 10; x++) {
            sprites[x][z] = new Sprite(texture);
            sprites[x][z].setPosition(x,z);
            sprites[x][z].setSize(1, 1);
         }
      }
 
      batch = new SpriteBatch();
 
      Gdx.input.setInputProcessor(this);
      matrix2.setToRotation(new Vector3(0, 1, 0), 90);
     
      bucket = new Sprite( new Texture(Gdx.files.internal("assets/bucket.png")));
      bucket.setPosition(-5, -5);
      bucket.setSize(1, 1);
   }

   @Override
   public void render(float delta) {
      Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
      cam.update();      
 
      batch.setProjectionMatrix(cam.combined);
      batch.setTransformMatrix(matrix);
      batch.begin();
      for(int z = 0; z < 10; z++) {
         for(int x = 0; x < 10; x++) {
            sprites[x][z].draw(batch);
         }
      }
      batch.end();
     
      batch.setTransformMatrix(matrix2);
      batch.begin();
      bucket.draw(batch);
      batch.end();
   }

but that way don't allow my future character to jump, only to walk.
I'm new to this world sory for my mistakes.
Thanks in advance for help Smiley
Offline Endos
« Reply #1 - Posted 2014-07-09 08:04:36 »

Just use an Orthographic camera and a background that simulates the perspective.

Bored Birds - End with your boredom for Android
Retroships - Space Shooter for Android
Ultimate - 2D Side-Scrolling Platformer project
Offline Kongo

Junior Newbie





« Reply #2 - Posted 2014-07-09 08:26:58 »

I think you misunderstood me, i don't want paralax background effect but something witch allow me to go x, y, z. I read a bit about decals and i think it is what i need. But there are lack of information about it. Any body knows some tutorial or know how i can get result with using it like this
Pages: [1]
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

Dwinin (28 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (76 views)
2014-09-10 06:39:09

Tekkerue (38 views)
2014-09-09 02:24:56

mitcheeb (58 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (35 views)
2014-09-07 01:11:22

Longarmx (35 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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!