Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A flash file (SWF) parser and viewer using OpenVG as the backend. Written in C++. (If you are looking for further development of this project contact me here at github)

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 Frameworks
Octocat-spinner-32 MonkSWF.xcodeproj
Octocat-spinner-32 projects
Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 MonkSWF.h
Octocat-spinner-32 readme.md
Octocat-spinner-32 svg2swf.rb
readme.md

MonkSWF -- An SWF Animation Player

Overview

MonkSWF is a SWF (Adobe Flash) animation player. It uses OpenVG as the rendering API. If your platform does not support OpenVG you can use MonkVG.

If you are looking to integrate this with your Cocos2D application there is an excellent article by Luke. Check it out: http://blog.zincroe.com/2011/11/displaying-a-swf-on-the-iphone-with-cocos2d-and-monkswf/

Installation

Use git to clone:

$ git clone git@github.com:micahpearlman/MonkSWF.git

If your platform does not support OpenVG download MonkVG with git:

$ git clone git@github.com:micahpearlman/MonkVG.git

There are currently iOS projects.

TODO: standard *nix Makefiles.

What is implemented

  • Most basic solid fills and strokes.
  • Sprite animations.

TODO

  • Bitmap fills and strokes.
  • Gradient fills and strokes.
  • Font Rendering.
  • Morph Targets.

Simple Example

NOTE: MonkVG will not create a OpenGL context, it is the applications responsibility to create there own OpenGL context. Also, if your application does any other OpenGL rendering it should save off the GL state and then restore before calling any MonkVG or MonkSWF methods.

Initialization:


    #include 
    #include 
    #include 
    
    char* filebuffer;
    int filebuffersize;
    ... Load The SWF File into a buffer ...
    MonkSWF::Reader r( filebuffer, filebuffersize );
            
    MonkSWF::SWF* swf = new SWF();
    swf->initialize();
    swf->read( &r );    // read in SWF file

Rendering and Animation

This example shows rendering the root SWF Movie.



    ... begin opengl context ...
    
    float deltaTime = calculateDeltaTime();
    if ( deltaTime > 1.0f / swf->getFrameRate() ) {
        frame++;
    }
    if ( frame >= swf->numFrames() ) {  // loop
        frame = 0;
    }
    
    // setup OpenVG
    vgLoadIdentity();
    vgRotate( angle );
    
    swf->drawFrame( frame );

    ... end opengl context ...

Alternatively you render a specific sprite in a SWF.


    // get a specific sprite
    MonkSWF::IDefineSpriteTag*  sprite = swf->spriteAt( spriteIdx );
    
    ... begin opengl context ...
    
    float deltaTime = calculateDeltaTime();
    if ( deltaTime > 1.0f / swf->getFrameRate() ) {
        frame++;
    }
    if ( frame >= sprite->frameCount() ) {  // loop
        frame = 0;
    }
    
    // setup OpenVG
    vgLoadIdentity();
    vgRotate( angle );
    
    sprite->draw( frame );

    ... end opengl context ...

Donate

Donate

Click here to lend your support to: MonkSWF and make a donation at www.pledgie.com !

Something went wrong with that request. Please try again.