private void drawAttacking(SpriteBatch batch) { Vector2 pos = character.getPosition(); float stateTime = character.attackAnimationHandler.stateTime; switch ((int) character.rotation) { case 0: batch.draw(attackE.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 45: batch.draw(attackNe.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 90: batch.draw(attackN.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 135: batch.draw(attackNw.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 180: batch.draw(attackW.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 225: batch.draw(attackSw.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 270: batch.draw(attackS.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 315: batch.draw(attackSe.getKeyFrame(stateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; } }
private void drawTippingOver(SpriteBatch batch) { Vector2 pos = character.getPosition(); tipOverStateTime += Gdx.graphics.getDeltaTime(); switch ((int) character.rotation) { case 0: batch.draw(tipOverE.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 45: batch.draw(tipOverNe.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 90: batch.draw(tipOverN.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 135: batch.draw(tipOverNw.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 180: batch.draw(tipOverW.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 225: batch.draw(tipOverSw.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 270: batch.draw(tipOverS.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; case 315: batch.draw(tipOverSe.getKeyFrame(tipOverStateTime), pos.x - 1.50f, pos.y - 1, 4, 4); break; } }
public void setRunninganimationDelay(float animationDuration) { runE.setAnimationDuration(animationDuration); runN.setAnimationDuration(animationDuration); runNe.setAnimationDuration(animationDuration); runNw.setAnimationDuration(animationDuration); runW.setAnimationDuration(animationDuration); runS.setAnimationDuration(animationDuration); runSe.setAnimationDuration(animationDuration); runSw.setAnimationDuration(animationDuration); }
public void setHitanimationDelay(float animationDuration) { hitE.setAnimationDuration(animationDuration); hitN.setAnimationDuration(animationDuration); hitNe.setAnimationDuration(animationDuration); hitNw.setAnimationDuration(animationDuration); hitW.setAnimationDuration(animationDuration); hitS.setAnimationDuration(animationDuration); hitSe.setAnimationDuration(animationDuration); hitSw.setAnimationDuration(animationDuration); }
public void setAttackAnimationDuration(float animationDuration) { attackN.setAnimationDuration(animationDuration); attackE.setAnimationDuration(animationDuration); attackNe.setAnimationDuration(animationDuration); attackNw.setAnimationDuration(animationDuration); attackW.setAnimationDuration(animationDuration); attackS.setAnimationDuration(animationDuration); attackSe.setAnimationDuration(animationDuration); attackSw.setAnimationDuration(animationDuration); }
private void setPlayTippingOver() { switch ((int) character.rotation) { case 0: tipOverSprite = new Sprite(tipOverE.getRegions()[11]); break; case 45: tipOverSprite = new Sprite(tipOverNe.getRegions()[11]); break; case 90: tipOverSprite = new Sprite(tipOverN.getRegions()[11]); break; case 135: tipOverSprite = new Sprite(tipOverNw.getRegions()[11]); break; case 180: tipOverSprite = new Sprite(tipOverW.getRegions()[11]); break; case 225: tipOverSprite = new Sprite(tipOverSw.getRegions()[11]); break; case 270: tipOverSprite = new Sprite(tipOverS.getRegions()[11]); break; case 315: tipOverSprite = new Sprite(tipOverSe.getRegions()[11]); break; } tipOverSprite.setBounds(character.getPosition().x - 1.5f, character.getPosition().y - 1, 4, 4); // For fading of killed animation Tween.registerAccessor(Sprite.class, new SpriteTween()); tweenManager = new TweenManager(); TweenCallback cb = new TweenCallback() { @Override public void onEvent(int type, BaseTween<?> source) { tweenCompleted(); } }; Tween.to(tipOverSprite, SpriteTween.ALPHA, 2.5f) .target(0) .ease(TweenEquations.easeInQuad) .setCallback(cb) .setCallbackTriggers(TweenCallback.COMPLETE) .start(tweenManager); }
private void drawRunning(SpriteBatch batch) { stateTime += Gdx.graphics.getDeltaTime(); Rectangle bounds = character.getBounds(); // Just update when the character is moving to prevent sudden change of animation if (character.isMoving()) { moveX = character.moveIndicatorX; moveY = character.moveIndicatorY; } // character is moving east if (moveX > 0) { // Moving north east if (moveY > 0) { batch.draw(runNe.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4); } else if (moveY < 0) { batch.draw(runSe.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4); } else { batch.draw(runE.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4); } // Moving west } else if (moveX < 0) { // Moving north if (moveY > 0) { batch.draw(runNw.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4); } else if (moveY < 0) { batch.draw(runSw.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4); } else { batch.draw(runW.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4); } } else { // Moving north if (moveY > 0) { batch.draw(runN.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4); } else if (moveY < 0) { batch.draw(runS.getKeyFrame(stateTime), bounds.x - 1.50f, bounds.y - 1, 4, 4); } } }