Java 类com.badlogic.gdx.physics.box2d.Box2D 实例源码

项目:FlappySpinner    文件:MenuScreen.java   
public MenuScreen(Game game) {
    Box2D.init();
    this.game = game;
    world = new World(new Vector2(0, 0), false);
    stage = new Stage(new StretchViewport(Constants.WIDTH, Constants.HEIGHT));

    preferences = new GamePreferences();
    audioManager = AudioManager.getInstance();
    Gdx.input.setInputProcessor(stage);

    FlappySpinner.gameManager.changeBackgroundColor("#4ec0ca");

    setUpBackground();
    setUpButtons();
    setUpLogo();
}
项目:TheEndlessCastle    文件:TheEndlessCastle.java   
@Override
public void create() {
    Box2D.init();

    _spriteBatch = new SpriteBatch();
    _modelBatch = new ModelBatch();
    _assetsHndlr = new AssetsHandler(_ASSETS_LIST_FILE_NAME);
    _settings = new Settings(_SETTINS_NAME);

    // Let shaders not use all available uniforms and attributes
    ShaderProgram.pedantic = false;
    // Disable for now bloom shader
    _settings.SetIsBloomShaderEnabled(false);

    setScreen(new LoadingScreen(this));
}
项目:FlappySpinner    文件:GameScreen.java   
public GameScreen(Game game, int score, boolean isRelife) {
    Box2D.init();

    SCORE = score;
    this.isRelife = isRelife;

    preferences = new GamePreferences();
    audioManager = AudioManager.getInstance();

    aGame = game;
    stage = new Stage(new StretchViewport(Constants.WIDTH, Constants.HEIGHT));
    world = WorldUtils.createWorld();
    world.setContactListener(this);

    FlappySpinner.gameManager.changeBackgroundColor("#e9fcd9");

    Gdx.input.setInputProcessor(stage);

    state = GameState.RESUME;

    setUpBackground();
    setUpTube();
    setUpSpinner();
    setUpGround();

    setUpOnPause();
    setUpOnResume();
    setUpOnFinish();

    setUpButtons();
    setUpLabels();
}
项目:Undertailor    文件:Undertailor.java   
@Override
public void create() {
    this.input = new InputRetriever(this);
    this.renderer = new MultiRenderer();
    Gdx.input.setInputProcessor(this.input);
    Box2D.init();

    this.assets = new AssetManager(this);
    this.environments = new EnvironmentManager(this);

    File assetDir = null;
    if (this.options.useCustomDir) {
        assetDir = this.options.assetDir;
    } else {
        assetDir = new File(System.getProperty("user.dir"));
    }

    this.assets.loadAll(assetDir);

    File mainFile = new File(assetDir, "main.lua");
    if (mainFile.exists()) {
        try {
            log.info("------------------ Executing main.lua script. ------------------");
            this.assets.getScriptManager().runScript(mainFile);
        } catch (FileNotFoundException wontHappen) {
        }
    } else {
        log.warn("main.lua was not found in game directory; no start code was executed");
    }
}
项目:libgdxjam    文件:LibgdxJam.java   
@Override
public void create () {
    logger = new Logger(LibgdxJam.class.getName(), Env.LOG_LEVEL);

    logger.info("create");

    Env.init(this);

    Box2D.init();

    categories = new Categories();
    tags = new Tags();

    assetManager = new AssetManager();
    assetManager.setLoader(
            SkeletonData.class,
            new SkeletonDataLoader(
                new InternalFileHandleResolver()
            )
        );
    assetManager.setLoader(
        OverlapScene.class,
        new OverlapSceneLoader(
            new InternalFileHandleResolver()
        )
    );
    assetManager.setLoader(
        PhysicsData.class,
        new PhysicsDataLoader(
            new InternalFileHandleResolver(),
            categories
        )
    );
    assetManager.setLoader(
        AnimationControl.class,
        new AnimationControlLoader(
            new InternalFileHandleResolver(),
            tags
        )
    );

    tweenManager = new TweenManager();
    Tween.registerAccessor(Camera.class, new CameraAccessor());

    uiCamera = new OrthographicCamera();
    uiViewport = new ExtendViewport(
        Env.MIN_UI_WIDTH,
        Env.MIN_UI_HEIGHT,
        Env.MAX_UI_WIDTH,
        Env.MAX_UI_HEIGHT,
        uiCamera
    );

    stage = new Stage(uiViewport);

    Gdx.input.setInputProcessor(inputMultiplexer);
    inputMultiplexer.addProcessor(stage);

    setScreen( Screens.getLoadingScreen() );
}
项目:practicos    文件:Clase.java   
@Override
public void create () {
    batch = new SpriteBatch();

    Box2D.init();
    mundo = new World(new Vector2(0, -9.8f), true);
    debugRenderer = new Box2DDebugRenderer();

    //crear la camara del mundo box2d
    camaramundo = new OrthographicCamera();
    camaramundo.setToOrtho(false, SCREEN_WIDTH/units, SCREEN_HEIGHT/units);



    //OBJETO PISO
    BodyDef cuerpoPiso = new BodyDef();
    cuerpoPiso.type = BodyType.StaticBody;
    //creamos una l�nea que representa el suelo, del ancho de la pantalla
    EdgeShape linea = new EdgeShape();
    linea.set(0, 20/units, SCREEN_WIDTH/units, 20/units);   
    //creamos el fixture
    FixtureDef fixDef=new FixtureDef();
    fixDef.shape=linea;
    fixDef.filter.categoryBits = BIT_PISO;
    fixDef.filter.maskBits = BIT_PELOTA | BIT_CAJA;
    //lo a�adimos al mundo
    piso = mundo.createBody(cuerpoPiso);
    piso.createFixture(fixDef).setUserData("piso"); // a�adimos el fixture al objeto

    //PAREDES
    cuerpoPiso.type = BodyType.StaticBody;
    //creamos una l�nea que representa la pared izquierda, del alto de la pantalla
    linea.set(0, 0, 0 , SCREEN_HEIGHT*2/units);     
    //creamos el fixture
    fixDef.shape=linea;
    fixDef.filter.categoryBits = BIT_PISO;
    fixDef.filter.maskBits = BIT_PELOTA | BIT_CAJA;
    //lo a�adimos al mundo
    piso = mundo.createBody(cuerpoPiso);
    piso.createFixture(fixDef).setUserData("pared"); // a�adimos el fixture al objeto

    cuerpoPiso.type = BodyType.StaticBody;
    //creamos una l�nea que representa la pared derecha, del alto de la pantalla
    linea.set(SCREEN_WIDTH/units, 0, SCREEN_WIDTH/units , SCREEN_HEIGHT*2/units);   
    //creamos el fixture
    fixDef.shape=linea;
    fixDef.filter.categoryBits = BIT_PISO;
    fixDef.filter.maskBits = BIT_PELOTA | BIT_CAJA;
    //lo a�adimos al mundo
    piso = mundo.createBody(cuerpoPiso);
    piso.createFixture(fixDef).setUserData("pared"); // a�adimos el fixture al objeto


    //OBJETO CAJA GIRATORIA
    BodyDef cuerpoCaja = new BodyDef();
    cuerpoCaja.type = BodyType.KinematicBody;
    cuerpoCaja.position.set(SCREEN_WIDTH/2/units, SCREEN_HEIGHT/4/units); 
    //creamos un rect�ngulo que representa la caja giratoria
    PolygonShape rectangulo = new PolygonShape();
    rectangulo.setAsBox(100/units, 10/units); 
    //creamos el fixture
    fixDef.shape=rectangulo;
    fixDef.filter.categoryBits = BIT_CAJA;
    fixDef.filter.maskBits = BIT_PELOTA;
    //lo a�adimos al mundo
    caja = mundo.createBody(cuerpoCaja);
    caja.createFixture(fixDef).setUserData("caja"); // a�adimos el fixture al objeto


    //es importante hacer dispose de los shapes despues de usarlos
    rectangulo.dispose();
    linea.dispose();

}
项目:0Bit-Engine    文件:GameScreen.java   
public GameScreen(ZBGame game) {
    super(game);
    Box2D.init();
}
项目:practicos    文件:GameWorld.java   
public GameWorld() {



    Box2D.init();

mundo = new World(new Vector2(0, -1.5f), true); // fuerza de gravedad de la tierra - 1 pixel = 1 metro.
                                                 // El valor boleano dice si los objetos pueden estar en reposo o no

mundo.setContactListener(new AdministradorColisiones());


  }
项目:practicos    文件:GameWorld.java   
public GameWorld() {



    Box2D.init();

mundo = new World(new Vector2(0, 0), true); // fuerza de gravedad de la tierra - 1 pixel = 1 metro.
                                                 // El valor boleano dice si los objetos pueden estar en reposo o no

//mundo.setContactListener(new AdministradorColisiones());


  }