Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (764)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (852)
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  
  Make invisible body line box2d libgdx  (Read 738 times)
0 Members and 1 Guest are viewing this topic.
Offline Armandotgt

Junior Newbie





« Posted 2017-11-19 23:18:43 »

I want to make these body lines invisible, because it's a lot that was left in the games, and that body circle too. The squares are of a layer tiled map. The circle is a body of a sprite.



Classes draw tiled map

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  
package com.mygdx.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.maps.MapObject;
import com.badlogic.gdx.maps.objects.RectangleMapObject;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.math.Rectangle;

import com.badlogic.gdx.physics.box2d.World;

public class B2CriaMundo {
   public B2CriaMundo(World mundo, TiledMap mapa) {
         
     
      for(MapObject obj : mapa.getLayers().get(1).getObjects().getByType(RectangleMapObject.class)) {
         Rectangle rect = ((RectangleMapObject) obj).getRectangle();
         
         new Meteoro(mundo, mapa, rect);
         
      }
   }
   
   public static void batida() {
      Gdx.app.log("Bateu:", "");
   }
}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
package com.mygdx.game;

import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.World;

public class Meteoro extends ObjetoInterativo{
   public Meteoro(World mundo, TiledMap mapa, Rectangle bounds) {
      super(mundo, mapa, bounds);
      fixture.setUserData(this);
   }

}


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  
package com.mygdx.game;

import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTile;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;

public abstract class ObjetoInterativo {
   protected World mundo;
   protected TiledMap mapa;
   protected TiledMapTile titulo;
   protected Rectangle bounds;
   protected Body corpo;
   protected Fixture fixture;
   
   public ObjetoInterativo(World mundo, TiledMap mapa, Rectangle bounds) {
      this.mundo = mundo;
      this.mapa = mapa;
      this.bounds = bounds;
     
      BodyDef corpoDef = new BodyDef();
      FixtureDef fdef = new FixtureDef();
      PolygonShape shape = new PolygonShape();
     
     
      corpoDef.type = BodyDef.BodyType.StaticBody;
      corpoDef.position.set((bounds.getX() + bounds.getWidth() /2) / ExGame.PPM, (bounds.getY() + bounds.getHeight() /2) / ExGame.PPM);
     
      corpo = mundo.createBody(corpoDef);
     
      shape.setAsBox(bounds.getWidth() /2 / ExGame.PPM, bounds.getHeight() /2 / ExGame.PPM);
      fdef.shape = shape;
      fixture = corpo.createFixture(fdef);
   }
   
}
Offline dime26

JGO Ninja


Medals: 72
Projects: 7
Exp: 12 years


Should traffic wardens be armed?


« Reply #1 - Posted 2017-11-19 23:28:03 »

Are you using the debug renderer to draw these outlines?

You should only use the debug renderer for debugging, maybe use a key to toggle it on / off.
Offline Armandotgt

Junior Newbie





« Reply #2 - Posted 2017-11-19 23:55:24 »

i'am drawing just a tiledmap like world, rectangles appear alone.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline dime26

JGO Ninja


Medals: 72
Projects: 7
Exp: 12 years


Should traffic wardens be armed?


« Reply #3 - Posted 2017-11-20 09:18:40 »

Can you show your render code please
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (591 views)
2018-06-10 19:43:48

EgonOlsen (694 views)
2018-06-10 19:43:44

EgonOlsen (478 views)
2018-06-10 19:43:20

DesertCoockie (831 views)
2018-05-13 18:23:11

nelsongames (1026 views)
2018-04-24 18:15:36

nelsongames (1083 views)
2018-04-24 18:14:32

ivj94 (1664 views)
2018-03-24 14:47:39

ivj94 (590 views)
2018-03-24 14:46:31

ivj94 (1501 views)
2018-03-24 14:43:53

Solater (569 views)
2018-03-17 05:04:08
Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46

Deployment and Packaging
by philfrei
2018-08-19 23:53:08

Deployment and Packaging
by philfrei
2018-08-19 23:50:04

Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39
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!