Git Product home page Git Product logo

flash2cocos2d's Introduction

FlashToCocos2D

This tool provides a fast way of reusing animations made in Flash CS in Cocos2D projects. A minimaly tweaked version of the amazing exporter by Grapefrukt provides a way to export all the animation information (position, rotation, scale) of a Flash made character to xml. The FlashToCocos iOS library reads those xml files and recreates the characters in Cocos2D.

Basic workflow:

FLASH SIDE:

- create your character in Flash - create as many animations a needed - every animation has to have a keyframe labeled with an unique name. IE: "*dancing*", "*running*"... - to launch custom events during an animation, you can use keyframes labels prefixed with @. IE: "*@launchSound*" - select 'Export for Actionscript' for your character MovieClip - add the Grapefukrt exporting code on the first frame:
```actionscript
import com.grapefrukt.exporter.simple.SimpleExport;
import com.grapefrukt.exporter.extractors.*;
// change robot for whatever name you want to use
var export:SimpleExport = new SimpleExport(this, "robot"); 
// change RobotCharacterMc for whatever name you MovieClip is in the library
export.textures.add(TextureExtractor.extract(new RobotCharacterMc)); 
AnimationExtractor.extract(export.animations, new RobotCharacterMc);
export.export();
```
  • publish
  • on the top left corner click on "click to output"
  • save the zip file
  • unzip the zip file

XCODE:

  • start a Cocos2D project
  • enabled ARC following this instructions
  • add the FlashToCocos Library
  • add the TBXML Library
  • add the results of unzipping the file created from Flash

FTCCharacter Class

Overview

FTCharacter is the main class to be used. It extends CCLayer and it's the responsible to load the XML files and textures. There are still a lot of methods exposed that shouldn't be. Hopefully we'll be able to clear the code a little bit in short time.

Class Methods

-(FTCharacter) characterFromXMLFile:(NSString *)xmlFileName

Reads and XML, loads texture and returns a FTCCharacter.
IE: FTCharacter *robot = [FTCharacter characterFromXMLFile:@"robot"]

Instance Methods

-(void) playAnimation:(NSString *)animation loop:(BOOL)loops wait:(BOOL)waits

Starts playing the specified animation. It will loop it if specified. The wait parameter indicates if this animation should wait for the previous one to finish before start playing.

-(void) stopAnimation

Stops the current animation being played.

-(void) pauseAnimation

Pauses the current animation.

-(void) resumeAnimation

Resumes the current paused animation.

-(void) playFrame:(int)_frameIndex fromAnimation:(NSString *)_animationId

Sets the character to the specified frame for the specified animation.

flash2cocos2d's People

Watchers

 avatar

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.