TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | May 2014 |
Maintained by Unclaimed.
This tool provides a fast way of reusing animations made in Flash CS in Cocos2D projects. A minimally tweaked version of the amazing exporter by Grapefrukt provides a way to export all the animation information (position, rotation, scale, alpha) of a Flash made character to xml. The FlashToCocos iOS library reads those xml files and recreates the characters in Cocos2D.
add Grapefrukt exporting code on the first frame. two sample uses:
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();
import com.grapefrukt.exporter.simple.*;
import com.grapefrukt.exporter.extractors.*;
import com.grapefrukt.exporter.textures.*;
const SCALE_RETINA = 1;
const SCALE_NON_RETINA = .5;
const COCOS_RETINA_EXT:String = "-hd";
// change robot for whatever name you want to use
var export:FTCSimpleExport = new FTCSimpleExport(this, "robot", stage.frameRate);
// change RobotCharacterMc for whatever name your MovieClip is in the library
AnimationExtractor.extract(export.animations, new RobotCharacterMc, null, true, 1);
var textureSheetRetina:TextureSheet = TextureExtractor.extract(new RobotCharacterMc, null, false, null, true, SCALE_RETINA, FTCBitmapTexture, COCOS_RETINA_EXT);
var textureSheetNonRetina:TextureSheet = TextureExtractor.extract(new RobotCharacterMc, null, false, null, true, SCALE_NON_RETINA);
export.texturesFile.add(textureSheetRetina);
export.texturesArt.add(textureSheetRetina);
export.texturesArt.add(textureSheetNonRetina);
export.export();
update publish settings with required Library path:
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.
-(FTCharacter) characterFromXMLFile:(NSString *)xmlFileName
Reads and XML, loads texture and returns a FTCCharacter.
IE: FTCharacter *robot = [FTCharacter characterFromXMLFile:@"robot"]
-(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.