Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (744)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (825)
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 205 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: 61
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: 61
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  
 
 

 
Ecumene (145 views)
2017-09-30 02:57:34

theagentd (213 views)
2017-09-26 18:23:31

cybrmynd (292 views)
2017-08-02 12:28:51

cybrmynd (284 views)
2017-08-02 12:19:43

cybrmynd (294 views)
2017-08-02 12:18:09

Sralse (287 views)
2017-07-25 17:13:48

Archive (966 views)
2017-04-27 17:45:51

buddyBro (1092 views)
2017-04-05 03:38:00

CopyableCougar4 (1663 views)
2017-03-24 15:39:42

theagentd (1425 views)
2017-03-24 15:32:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

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

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
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!