public Hammer() { super(); final PolygonShape boxShape = new PolygonShape(); final BodyDef hammerBodyDef = new BodyDef(); hammerBodyDef.type = BodyDef.BodyType.KinematicBody; hammerBodyDef.position.set(0, 0); body = world.createBody(hammerBodyDef); boxShape.setAsBox(1.5f, 1.5f); body.createFixture(boxShape, 0); boxShape.dispose(); // setup animation final Assets assets = Locator.getAssets(); final SkeletonData skeletonData = assets.getSkeletonData(Assets.Animations.OBST_HAMMER); skeleton = new Skeleton(skeletonData); animation = skeletonData.findAnimation("trigger"); animationState = new AnimationState(assets.getAnimationStateData(Assets.Animations.OBST_HAMMER)); animationState.addListener( new AnimationState.AnimationStateListener() { @Override public void start(int trackIndex) {} @Override public void event(int trackIndex, Event event) { if (event.getData().getName().equals("smashed")) { if (isBloodied) { skeleton.setAttachment("obst_hammer", "hammer_hammer_bloodied"); } } } @Override public void end(int trackIndex) {} @Override public void complete(int trackIndex, int loopCount) {} }); bone = getBone(skeleton, SLOT_NAME); }
public Gamescreen(Jamwteatrze game) { this.game = game; // set game state currentState = GameState.TITLE; // currentState = GameState.MAP; // currentState = GameState.ARENA; batch = new SpriteBatch(); camera = new OrthographicCamera(1280, 720); camera.position.set(camera.viewportWidth / 2f, camera.viewportHeight / 2f, 0); viewport = new FitViewport(1280, 720, camera); camera.update(); // spine sr = new SkeletonRenderer(); dr = new SkeletonRendererDebug(); dr.setBoundingBoxes(false); dr.setRegionAttachments(false); // stage stage = new Stage(viewport, batch); stageCharacters = new Stage(viewport, batch); Gdx.input.setInputProcessor(stage); // ----------------- DEKLARACJE playerIcon = new SpineActor(batch, sr, shpr, "characters/goral", true, game.player.playerHp); playerIcon.setPosition(-400, 180); stageCharacters.addActor(playerIcon); generujEnemys(); // atakuj button atakujTex = Assets.manager.get(Assets.atakuj, Texture.class); atakujTex.setFilter(TextureFilter.Linear, TextureFilter.Linear); atakujButton = new ImageButton(new SpriteDrawable(new Sprite(atakujTex))); atakujButton.setPosition(565, -200); atakujButton.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (pulaGracza > 0 && !atakowanie) { atakowanie = true; System.out.println("atakuj button pressed"); atakuj(); } return true; } }); stage.addActor(atakujButton); // gui font = Assets.manager.get(Assets.myFont, BitmapFont.class); font.getData().setScale(0.7f); font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); scena = Assets.manager.get(Assets.scena, Texture.class); scena.setFilter(TextureFilter.Linear, TextureFilter.Linear); panel = Assets.manager.get(Assets.panel, Texture.class); panel.setFilter(TextureFilter.Linear, TextureFilter.Linear); // tla swiat00tlo = Assets.manager.get(Assets.swiat00tlo, Texture.class); swiat00tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear); swiat01tlo = Assets.manager.get(Assets.swiat01tlo, Texture.class); swiat01tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear); swiat02tlo = Assets.manager.get(Assets.swiat02tlo, Texture.class); swiat02tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear); swiat03tlo = Assets.manager.get(Assets.swiat03tlo, Texture.class); swiat03tlo.setFilter(TextureFilter.Linear, TextureFilter.Linear); kowadloTex = Assets.manager.get(Assets.kowadloTex, Texture.class); kowadloTex.setFilter(TextureFilter.Linear, TextureFilter.Linear); // kowadlo = new Sprite(kowadloTex); // kowadlo.setPosition(100, 100); // DICES heroDices = new Array<Dice>(); enemyDices = new Array<Dice>(); // ------ generate hero dieces heroDices.add(new Dice(this, true)); heroDices.add(new Dice(this, true)); // heroDices.add(new Dice(this)); numberHeroDieces = heroDices.size; baseHeroDieces = numberHeroDieces; for (Dice dice : heroDices) { // dice.debug(); dice.setTouchable(Touchable.disabled); dice.setVisible(false); stage.addActor(dice); } // ------ generate enemy dieces enemyDices.add(new Dice(this, false)); enemyDices.add(new Dice(this, false)); numberEnemyDieces = enemyDices.size; baseEnemyDieces = numberEnemyDieces; for (int i = 0; i < enemyDices.size; i++) { enemyDices.get(i).setPosition(725 + (i * 133), -150); if (!heroTurn) { enemyDices.get(i).addAction(moveTo(725 + (i * 133), 37, 1.0f, Interpolation.bounceOut)); } } for (Dice dice : enemyDices) { // dice.debug(); stage.addActor(dice); } // kotara kotaraAtlas = new TextureAtlas(Gdx.files.internal("gui/kotara.atlas")); kotaraJson = new SkeletonJson(kotaraAtlas); kotaraSkeletonData = kotaraJson.readSkeletonData(Gdx.files.internal("gui/kotara.json")); kotaraSkeleton = new Skeleton(kotaraSkeletonData); kotaraIdleAnimation = kotaraSkeletonData.findAnimation("idle"); AnimationStateData stateData = new AnimationStateData(kotaraSkeletonData); kotaraState = new AnimationState(stateData); kotaraState.addAnimation(0, "idle", true, 0); kotaraSkeleton.setPosition(-200, -150); // title title = new SpineButton(batch, sr, "gui/title", "idle", 100, 0, 800, 600); // title.debug(); title.setClicked(false); if (currentState == GameState.TITLE) { resetTitle(); } // title listeners title.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (!title.isClicked() && title.getY() <= 20) { title.setClicked(true); fadeOutTitle(Gdx.graphics.getDeltaTime()); } return true; } }); stage.addActor(title); // mapa mapa = new SpineButton(batch, sr, "gui/mapa", "show0", 100, 0, 800, 600); mapa.setPosition(mapaX, -900); // mapa.debug(); mapa.setClicked(false); // mapa listeners TODO! mapa.addListener( new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { fadeOutMapa(Gdx.graphics.getDeltaTime()); return true; } }); stage.addActor(mapa); // if (currentState == GameState.ARENA) { // resetArena(); // } }