Skip to content

Animations

Millie Macdonald edited this page Jan 18, 2017 · 1 revision

The Animations class is designed to be extended for the UserAnimations class and the AIAnimations class. It contains methods for adding animations to queues such that they play in sequence. As well as being able to run all the Animations which are queued. It should not be used by itself.

The goal when creating an animation is to create a timeline of actions upon an object that is stored in GameState. All drawing of objects in a game is handled in GameState, so all you have to do is update the coordinates/add and remove in GameState. Hence if you create a timeline of events at 60fps, it'll be displayed at 60fps. However if you create a timeline of events at 10fps, it'll display at that. 60fps is the cap that this game can run at.

The fundamental concept to understand with this implementation is that everything happens on a callback. If you create a new animation using one of the functions in this class, you can add it to the queue using addToAnimationQueue(animation, queueType). It'll add it to a queue and run it when that queue is available for running. Your animation must have a callback to animationFinished such that it can be removed and the next animation sequenced.

Add your animation to the correct queue and it will play when it is required. There are six queues available:

  • AI_PLAYING
  • AI_REFILLING
  • USER_REFILLING
  • NON-BLOCKING
  • GRAVEYARD
  • AI_GRINDER

It is important to note that animations are created with an AnimationCallback interface. This means that when your animation is done/sequence of animations is done, you can get a notification in whatever class you are working in. This callback interface only calls the method when the queue is done.

Methods Returns Params Description
addToAnimationQueue void Animation animation, Integer queueType Adds animation to a queue to be executed.
runAnimationQueues void MatchCard card, RecTile tile Executes current animation queue.
isAnimating boolean Integer queue checks if queue is being animated.
checkFinished void Integer queue checks if animation has finished execution.
animationFinished void MatchCard card remove completed animation from queue.
animatePyramidRefill void Integer count, boolean isUser animation to refill pyramid depending on User type.
Timeline animateCardMovement animation MatchCard card, Integer toX, Integer toY Create animation for card movement from current location to toX and to toY.
animateGraveyard void Match match Removes card from the board and moves it to the graveyard.
Timeline attackAnimation animation int x, int y Attack animation between two cards on the game board.
pyramidRefillFlipCards void - Triggers flipCard after the user's pyramid has been refilled on top level cards.
flipCard void MatchCard card, CardHiddenState fromState, CardHiddenState toState, final Integer flipType Flips card from the current state(fromState) to the desired state(toState). flipType is used to determine which flip needs to be applied to the given card.
RotateTransition createRotator RotateTransition rotator ImageView card, boolean firstRotator firstRotator is used to determine if the card needs to be flipped to halfway or from halfway to the end.

AIAnimations

The AIAnimations class extends the Animation class and handles all the computer players animations (ie. the Artificial Intelligence (AI) player). Any animation which is generated by the AI is created through the methods used within this class and subsequently added to the animations queue to be called in the correct sequence of animations. The callback passed in through the constructor is used to notify when the queues are done hence blocking user interaction.

Methods Returns Params Description
animatePyramidRefill void - Creates the animation for AI pyramid refill and adds it to the animation queue.
animateAIMove void MatchCard card, RecTile tile Creates the animation for the AI card to movement and flip to the animation queue.
grindCard void MatchCard card Adds the AI card grinding animation to the animation queue.

UserAnimations

The UserAnimations class extends the Animations class and handles all the user(s) animations. Any animation which is generated by the user is created through the methods used within this class and then subsequently added to the animations queue to be called in the correct sequence of animations. The callback passed in through the constructor is used to notify when the queues are done hence blocking user interaction with the semi-filled pyramid.

Methods Returns Params Description
animatePyramidRefill void - Triggers pyramid refill when the user runs out of cards.
flipCards void List cardList Takes the cards in the given list and invokes the flipCard method on them.
emit void Emitter emitter, MatchCard card Sets the centre of the card to the initial x and y point for the emitter and emits from that point.

Home

Saving and Loading

Statistics tracking

Game Play

APIs


Game Guide

Other Guides

Design Guides

Overviews

Features

Animations

Splash Screen & Create Account Screen

Player Account Settings

AI

Duck Dust


Brainstorming


Future Development


http://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gifhttp://cultofthepartyparrot.com/parrots/partyparrot.gif

Clone this wiki locally