Using Gree's SWF with cocos2d-html5

Hi,

Does anybody have used LWF on Cocos2d-html5? https://github.com/gree/lwf

It says it is compatible, but I would know if anybody did really use it, and if there are problems of any kind (performance, configuration, etc) associated to it.

Also, I would like to know if it’s possible to export flash assets as spritesheets.

Thanks,

JB

Hey JB,

Thank you for interesting in LWF :smiley: I noticed that LWF for cocos2d-html5 was not compatible with v2.2, so I have updated it and created a demo using Flash assets, which was converted into LWF data, on cocos2d-html5 template app.

LWF live demo on cocos2d-html5
http://gree.github.io/lwf-demo/cocos2d-html5/hello-lwf/index.html (WebGL or Canvas, automatically)

Source code

I have never tested it on cocos2d-x JavaScript binding yet, but it might work with some modification.

We also have more LWF for HTML5 demos, it means these demos are not on cocos2d-html5, however the LWF data (Flash data) and the embedded JavaScripts basically works on cocos2d-html5 as well. (Some demos actually uses HTML5 special feature which is not supported on cocos2d-html5, but the others should work.)

hi, many thanks for this. What version of Flash is required to generate the SWF, or it doesn’t matter? thanks

It doesn’t matter for simple animation. you can convert from SWF version 7 file. But actually there are many restriction for LWF, like http://gree.github.io/lwf-demo/pdf/FLASHforLWFproductionguideline.pdf , because the goal of LWF is not for making yet-another-Flash-player-implementation, LWF just uses Flash for the convenience for authoring 2D animation (as you know, Adobe Flash is one of the best tool for creating 2D animation).

If you want to write JavaScript on the action panel of Flash, I recommend you to use Flash CS6. Flash CC is also supported, but we don’t use Flash CC so much.

LWFS, the tool for conveting to LWF data from Flash data, helps you a lot. Please take a look at the document.

Hi Kazuki,cool.
The demo runs smooth, 60fps on 9100+UC. It will be a powerful tool for game developers. Thanks for bringing us so a wonderful tool.

However, it is a bit slow when LWF loading, parsing and creating. Do you have any plan to optimize it?

Hi Shun, thanks and welcome.

Do you have any plan to optimize it?
Yeah, I can implement parsing LWF using Web Workers. It will improve the performance during that time.
Also cc.LoaderScene.preload would help for the loading time as well.

Did anybody experiment this error when executing swf2lwf? Is a very simple SWF generated by Flash CC

C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:370:in `encode_png_pi
xels_to_scanline_method’: No encoder found for color mode 4 and 8-bit depth! (Ch
unkyPNG::NotSupported)
from C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:210:in `
encode_png_image_pass_to_stream’
from C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:174:in `
encode_png_image_without_interlacing’
from C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:161:in `
encode_png_pixelstream’
from C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:85:in `t
o_datastream’
from C:/LWF/tools/swf2lwf/lib/chunky_png/image.rb:62:in `to_datastream’
from C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:35:in `w
rite’
from C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:43:in `b
lock in save’
from C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:43:in `o
pen’
from C:/LWF/tools/swf2lwf/lib/chunky_png/canvas/png_encoding.rb:43:in `s
ave’
from C:/LWF/tools/swf2lwf/swf2lwf.rb:196:in `export_png’
from C:/LWF/tools/swf2lwf/swf2lwf.rb:1005:in `export_png’
from C:/LWF/tools/swf2lwf/swf2lwf.rb:4166:in `block in swf2lwf’
from C:/LWF/tools/swf2lwf/swf2lwf.rb:4166:in `map’
from C:/LWF/tools/swf2lwf/swf2lwf.rb:4166:in `swf2lwf’
from C:/LWF/tools/swf2lwf/swf2lwf.rb:4210:in `’

Have you tried LWFS https://github.com/gree/lwfs ? I have tested your data with LWFS, it worked.

Hi Kazuki, is there Gree’s game using cocos2d-x or cocos2d-html5?

Hey Zhe, at least, I don’t use it for production so far.

Hi,

We released LWF for C++ with Cocos2d-x renderer!
Please take a look at http://www.cocos2d-x.org/forums/18/topics/40551

Hi Kazuki,

this is great tool. I am trying to use it on cocos2d-x js binding (v.2.2.1). After some modification, it will show on the screen, but always play the first frame. It plays correctly on cocos2d-html5. Could you have a look, or share a official version ? Thanks.

Hi Norris,

Norris Tong wrote:

this is great tool. I am trying to use it on cocos2d-x js binding (v.2.2.1). After some modification, it will show on the screen, but always play the first frame. It plays correctly on cocos2d-html5. Could you have a look, or share a official version ? Thanks.

Could you share your modification? I’ve never tried it on cocos2d-x jsb. I’ll take a look it. Thanks.

Added LWF to Cocos2d-x Hub! http://www.cocos2d-x.org/hub/103

Hello!
I add lwf movie like this:

        var parentNode = this;
        var lwfCache = LWF.ResourceCache.get();
        lwfCache.loadLWFNode({
            lwf:"movie.lwf",
            fitForHeight:true,
            onload:function(lwfNode) {
                parentNode.addChild(lwfNode);
            }
        });

How can i handle movie finished playing?

Mykyta Usikov wrote:

Hello!
I add lwf movie like this:

        var parentNode = this;
        var lwfCache = LWF.ResourceCache.get();
        lwfCache.loadLWFNode({
            lwf:"movie.lwf",
            fitForHeight:true,
            onload:function(lwfNode) {
                parentNode.addChild(lwfNode);
            }
        });

How can i handle movie finished playing?

Hello Mykyta!

Put “fscommand(‘event’, ‘done’);” on ActionScript panel at the end of the movie which you want to handle finished playing.

    lwfNode.getLWF().addEventListener("done", function() {
        // the movie finished playing
    });

Kazuki Sakamoto wrote:

Put “fscommand(‘event’, ‘done’);” on ActionScript panel at the end of the movie which you want to handle finished playing.

    lwfNode.getLWF().addEventListener("done", function() {
        // the movie finished playing
    });

Thanks!
That worked perfectly!
P.S. i also had to switch to ActionScript version 1.0 according to “FLASH for LWF production guideline”

Has anyone experimented this with v3 of cocos2d-js?

this is awesome, @splhack . Do you plan to update html5 version with cocos2d-x 3.8 (JS)?