LWF for C++ with Cocos2d-x renderer

Herman To wrote:

I’m using VS2012. It’s solved now, I changed LWF class to LWFCore.

good to hear.

I got another question, is there convenient way to support batching with texture atlas generated from Texturepacker? I tried this code :

Yeah,

  1. Do “Publish for LWF” on Flash CS6 or Flash CC, for example, the filename is “sample.fla”. It generates “sample.bitmap” folder which includes all bitmaps in the fla file.
  2. Generate texture sheet using TexturePacker from the PNG files in “sample.bitmap” and publish the texture sheet with “JSON Hash”, for example, “sample_atlas.json” and “sample_atlas.png”. (You can do it in command line, like “$ texturepacker —format json —shape-padding 0 —border-padding 0 —padding 0 —inner-padding 0 —no-trim —maxrects-heuristics best —disable-auto-alias —reduce-border-artifacts —scale 1 —data sample_atlas.json —sheet sample_atlas.png sample.bitmap/*png”)
  3. Put the texture sheet json and png into LWFS_work project folder. For example LWFS_work/sample/sample.fla, LWFS_work/sample/sample.swf, LWFS_work/sample/sample_atlas.json, LWFS_work/sample/sample_atlas.png

That’s it. You can use LWFNode using “sample.lwf” and “sample_atlas.png” with SpriteBatchNode.

By the way, from Cocos2d-x 3.0beta, if you convert lwf data with a texture atlas, Cocos2d-x automatically batches LWFNodes without SpriteBatchNode :slight_smile:

Hi, everything works perfectly, thanks… Batch is done automatically also, nice :slight_smile:

Is there documentation on how to implement button event handler? there is documentation only for unity and cocos2d-html5

Herman To wrote:

Hi, everything works perfectly, thanks… Batch is done automatically also, nice :slight_smile:

good to hear and thanks :wink:

Is there documentation on how to implement button event handler? there is documentation only for unity and cocos2d-html5

Objective-C API document is also available, however no document for C++ implementation… You can use LWF::AddButtonEventHandler API, but more easy way is LWF::AddEventHandler API like this .

In Flash, put

fscommand("event", "done");

into button action as the following.

on (release) {
    fscommand("event", "done");
}

The first argument should be “event”, the second argument is event name.
And then use AddEventHandler with the event name “done”.

lwfNode->lwf->AddEventHandler("done", [=](LWF::Movie *, LWF::Button *){
    lwfNode->lwf->GotoAndPlayMovie("_root", 1);
});

Tried the button on cat demo LWFS work examples, and not working also… I’m really confused…

This is my actionscript on button
on(release)
{
fscommand(“event”, “done”);
}

Can’t we get the movieclip or button node from C++ code then assign standard cocos2d event handler?

problem solved, it’s because i was using publish to lwf, should be just using file-publish.

I still have performance issue on my android phone. I already batched the rendering using SpriteBatchNode ( since I’m switching back to alpha1 ). I just get 20-40 FPS on my phone with only 2 draws. The LWF itself just contains 3 bitmaps and 2 buttons ( 800x480 resolution).

While my game with 16 draws can run 60fps on the same phone.

Anyway, thanks for the great LWF :slight_smile:

Herman To wrote:

problem solved, it’s because i was using publish to lwf, should be just using file-publish.

We found and fixed a problem in the converter with using “Publish for LWF”, we’ll release it soon. Thank you for the report!

Herman To wrote:

I still have performance issue on my android phone. I already batched the rendering using SpriteBatchNode ( since I’m switching back to alpha1 ). I just get 20-40 FPS on my phone with only 2 draws. The LWF itself just contains 3 bitmaps and 2 buttons ( 800x480 resolution).

Hmm, could you share the content (fla file) with me?

Kazuki Sakamoto wrote:

Herman To wrote:
> problem solved, it’s because i was using publish to lwf, should be just using file-publish.
>
We found and fixed a problem in the converter with using “Publish for LWF”, we’ll release it soon. Thank you for the report!

Thanks… It’s because “Publish for LWF” automatically changing flash player version to 8, which then break the actionscript

Kazuki Sakamoto wrote:

Herman To wrote:
> I still have performance issue on my android phone. I already batched the rendering using SpriteBatchNode ( since I’m switching back to alpha1 ). I just get 20-40 FPS on my phone with only 2 draws. The LWF itself just contains 3 bitmaps and 2 buttons ( 800x480 resolution).
>
Hmm, could you share the content (fla file) with me?

I tried with the demo animated_building.lwf from LWFS work examples, is the same, FPS can’t reach more than 40 FPS. I’m using HTC One V with Android OS 4.0.3.

solved… it’s my game’s code that’s causing the slow down… thanks so much for the help… :slight_smile:

Waiting for updated LWFS’ “Publish for LWF”

Herman To wrote:

solved… it’s my game’s code that’s causing the slow down… thanks so much for the help… :slight_smile:

np.

Waiting for updated LWFS’ “Publish for LWF”

Could you try the latest one? https://github.com/gree/lwfs

I tried the latest Commands-Publish For LWFS.jsfl. Got “NG” on daemon’s status.
This is the message : http://pastebin.com/WPL6rEbE

If I use File-Publish, it works. I think it’s because the jsfl is automatically changing to Flash Player 8. So, I tried changing the jsfl

doc.setPlayerVersion(7);

And it works… Problem solved! :slight_smile: Still don’t know though if it’s going to break other things.

ps: I’m using Flash CS6.

Herman To wrote:

I tried the latest Commands-Publish For LWFS.jsfl. Got “NG” on daemon’s status.
This is the message : http://pastebin.com/WPL6rEbE

eh, thank you for the report. we noticed that Flash CS6 exports another shape tag if we created rectangle shape with line color (creating rectangle shape without line color is no problem with the current LWFS). we’ll fix and release LWFS soon.

Could you retry the latest one? https://github.com/gree/lwfs

It’s working perfectly now… Thank you :slight_smile: :smiley:

There is still problem, while the status says “OK” on the daemon, but actionscript is not exported. My tellTarget script seems to be not working. But it’s working on publish setting with flash player version 7.

Oh, thank you for your report! We have fixed the problem. Would you check the latest LWFS https://github.com/gree/lwfs again? We really appreciate your cooperation :slight_smile:

Still not working, but daemon says “OK”… I don’t know why, is it merely because flash player version issue? If I change to flash player 7 and publish it without “Publish with LWF”, it works