public GameScreenManager(float step, World world) { this.world = world; dt = step; WIDTH = Gdx.graphics.getWidth(); HEIGHT = Gdx.graphics.getHeight(); float rate = (float) ((double) refereansWidth / (double) WIDTH); PPM_W = rate; PPM_H = (float) ((double) refereansHeight / (double) HEIGHT); // set up box2d cam orthoCam = new OrthographicCamera(); orthoCam.setToOrtho(false, WIDTH, HEIGHT); box2DDebugRenderer = new Box2DDebugRenderer(); player = Player.getPlayer(); player.anim = AnimationManager.getInstance() .getAnimation(AnimationManager.SPRITE_WALKING_RIGHT, "walkright"); Weapon.getWeapon().anim = AnimationManager.getInstance().getAnimation(AnimationManager.WEAPON, "weapon"); }
private void renderPlayerInfo(SpriteBatch spriteBatch) { Texture texture = FileManager.getManager().getTexture(FileManager.RETRY_COUNT_IMAGE, "count"); for (int i = 0; i < Player.getPlayer().lifeCount; ++i) { spriteBatch.draw( texture, getScreenWidth() - (30 * (i + 1)) / GameScreenManager.PPM_W, 20 / GameScreenManager.PPM_H, 30 / GameScreenManager.PPM_W, 30 / GameScreenManager.PPM_H); } BitmapFont font = FileManager.getManager().getFont(); font.setColor(1.0f, 1.0f, 1.0f, 1.0f); font.draw( spriteBatch, "SCORE : " + Player.getPlayer().score, 50 / GameScreenManager.PPM_W, 50 / GameScreenManager.PPM_H, (int) 30 / GameScreenManager.PPM_H, 10, false); }
@Override public void render(SpriteBatch spriteBatch) { // clear screen Gdx.gl.glClear(Gdx.gl.GL_COLOR_BUFFER_BIT); Texture texture = FileManager.getManager().getTexture(null, "background"); spriteBatch.begin(); // Background spriteBatch.draw(texture, startScreenX(), startScreenY(), getScreenWidth(), getScreenHeight()); renderBalls(spriteBatch); renderPlayerInfo(spriteBatch); // player player = Player.getPlayer(); TextureRegion textureRegion = player.anim.getKeyFrame(passedTime, true); TextureRegion textureRegion1 = Weapon.getWeapon().anim.getKeyFrame(passedTime, true); weapon = Weapon.getWeapon(); spriteBatch.draw( textureRegion, player.playerBody.getPosition().x - player.width / 2, player.playerBody.getPosition().y - player.height / 2, player.width, player.height); // Weapon draw while actived by touch if (Weapon.getWeapon().isActive) { spriteBatch.draw( textureRegion1, weapon.weaponBody.getPosition().x - weapon.width / 2, weapon.weaponBody.getPosition().y - weapon.height / 2, weapon.width, weapon.height); } else { if (Weapon.getWeapon().weaponBody != null) Weapon.getWeapon().weaponBody.setActive(false); } spriteBatch.end(); // draw box2d world box2DDebugRenderer.render(world, orthoCam.combined); }
public Player getPlayer() { return Player.getPlayer(); }
public void setPlayerAnim(Animation anim) { Player.getPlayer().anim = anim; }
public static void createPlayer() { Player.getPlayer().createPlayer(world); }