Coder Social home page Coder Social logo

cfaaction's Introduction

CFAAction

Build Status

CFAAction is a wrapper around several common Core Animation animations that provides additional modularity and the ability to group and sequence actions.

Getting Started

CFAAction's should be treated like SKAction's, which means they are only run when they are submitted to a variant of -[CALayer runAction:].

To run an action that moves a layer 10 pixels to the right in 1 second, for example, you can do:

CFAAction *moveAction = [CFAAction moveByX:10 y:0 duration:1];
[self.view.layer runAction:growAnimation];

Completion blocks can be used to sequence animations:

CFAAction *rotateAction = [CFAAction rotateToAngle:M_PI duration:1];
CFAAction *growAnimation = [CFAAction resizeToHeight:400 duration:0.25];

[self.view.layer runAction:rotateAction completion:^{
	[self.view.layer runAction:growAnimation];
}];

But, so can +[CFAAction sequence:]:

CFAAction *rotateAction = [CFAAction rotateToAngle:M_PI duration:1];
CFAAction *growAnimation = [CFAAction resizeToHeight:400 duration:0.25];

[self.view.layer runAction:[CFAAction sequence:@[ rotateAction, growAnimation ]];

To run actions concurrently, there's +[CFAAction group:]:

CFAAction *rotateAction = [CFAAction rotateToAngle:M_PI duration:1];
CFAAction *scaleAnimation = [CFAAction scaleBy:-0.25 duration:0.25];
[self.view.layer runAction:[CFAAction group:@[ scaleAnimation, rotateAction ]]];

To perform a block or selector as an action, use [CFAAnimation runBlock:], [CFAAnimation runBlock:queue:], or [CFAAnimation performSelector:onTarget:]. When used in a group with a wait action, these can act as extensions for the total duration of the grouping. When used in a sequence, they can act as delays before or after the selector is performed for precision timing.

[self.planeLayer runAction:[CFAAction sequence:@[ bankAndRollAction, [CFAAction repeatAction:fireAction count:6] ]] completion:^{
		[self.enemy runAction:[CFAAction sequence:@[ dieAction, [CFAAction performSelector:@selector(die:) onTarget:self.enemy], [CFAAction waitForDuration:0.5] ]]];
}];

License

CFAAction is licensed under the MIT license. See LICENSE.md.

Contact

Follow me on Twitter @CodaFi_, or visit my website.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.