@Override public void tick() throws IllegalStateException { if (mGameObject == null) throw new IllegalStateException("GameObject for AnimationGameComponent is null."); if (mCurrentAnimation == null) throw new IllegalStateException("Current Animation for AnimationGameComponent is null"); mCurrentAnimation.tick(); }
/** * setAnimation sets the current animation being played for the GameObject * * @param animationName - The name of the animation that should be played */ public void setAnimation(String animationName) throws IllegalStateException { try { mCurrentAnimation = mGameObjectAnimations.get(animationName); mCurrentAnimation.start(); } catch (NullPointerException e) { throw new IllegalStateException( "Animation " + animationName + " was never added to AnimationComponent"); } }
@Override public void render(Graphics g) throws IllegalStateException { if (mCurrentAnimation == null) throw new IllegalStateException("Current Animation for AnimationGameComponent is null"); g.drawImage( mCurrentAnimation.getSprite(), mGameObject.getxPosition(), mGameObject.getyPosition(), null); }
/** stopAnimating will stop the GameObject's animations */ public void stopAnimating() { mCurrentAnimation.stop(); mCurrentAnimation.reset(); }