Re: Getting Started with Animations


Dave
 

Hi Again,

I’ve taken a look at Geek Game Board and I’m finding it a but hard to know where to start. I’ve developed my game to the point where the game engine sends messages to the Game View Controller which cause a Subview to the Game Cell. I now just want to animate that process, so basically in my view controller I want the View to fly across the screen from the left player area to a position in the board view. In order to do this, do I create a new CALayer or do I use the CALayer of the View I’m moving. I’m just having problems seeing where I add the code, simplified, the it looks like this:

GameViewController
RootView
LeftView
ScrollView
PieceView This View is taken from the Scroll View and 
RightView
BoardView
CellView1 to CellView81  Added as a Subview of one of these Views.


If anyone knows of a really simple Sample App that shows how to do this I’d be really grateful if you could point me to it. 

All the Best
Dave

On 13 Jul 2017, at 18:15, Jens Alfke <jens@...> wrote:


On Jul 13, 2017, at 6:13 AM, Dave <dave@...> wrote:

What is the best way to achieve this? Do I use CALayer? 

Yup, I would recommend using CALayers for the whole UI, pretty much. Back when Core Animation first came out I wrote a framework for building board/card games:
It hasn’t been updated since 2011 so it probably needs some fixes for API changes, but I still think the basic design is pretty well thought out. The goal was that you could implement a simple game UI in <200 lines of code, and there are examples included for checkers, tic-tac-toe, Klondike solitaire, and a few others.

—Jens

Join cocoa@apple-dev.groups.io to automatically receive all group messages.