a framework for 2D User Interface and 2D Animation
Lightweight SWF
based on an animation data converted from a Flash SWF file.
Yet another Flash Player implementation
Make Game Development HAPPY!
Animators make good animations
Programmers implement animations as good as they can do
Adobe Flash is one of the most powerful and useful tool for authoring 2D animation
Animators can make too many animations, Do not forget adapting Performance and Memory Usage
You can get easily "Bitmap" from "Shape"
Flash Professional / Converting art between vector and bitmap formats (CS5.5 or later)
You can also use JSFL for converting shapes into bitmaps.
logo.swf
$ ruby swf2lwf.rb logo.swf
Generates logo.lwf
Yes! It is embedded LWF Runtime for HTML5 with Canvas Renderer
Embedded LWF Runtime for HTML5 with Canvas Renderer
It means you can port LWF for XNA and PlayStation Mobile SDK!
It just works as Flash Player
AddEventHandler API
/* In Flash action panel */
fscommand("event", "eventName");
/* In C# */
AddEventHandler("eventName", (movie,button) => {
Debug.Log("[EVENT] eventName");
/* movie: Movie instance where the event was occurred at */
/* button: Button instance where the event was occurred at */
});
It makes possible to handle the end of animation, user interaction and so forth
AddMovieEventHandler API
AddMovieEventHandler("instanceName", load:(movie) => {
Debug.Log("instanceName has been loaded");
});
AddMovieEventHandler("instanceName",
enterFrame:(movie) => {
/* enterFrame */
},
unload:(movie) => {
/* unload */
}
);
It can handle the Movie events like load, enterFrame, unload and so on as well as Flash ActionScript
enterFrame:(movie) => {
/* handle the event */
},
It's so meaningful, isn't it?
AddButtonEventHandler API
AddButtonEventHandler("instanceName", press:(button) => {
Debug.Log("instanceName has been pressed");
});
It can handle the Button events like press, release, rollOver, rollOut and so on as well as Flash ActionScript
You can implement the renderers of these using the renderer interface what you want to do with the geometry, color and size information
See also FLASH for LWF production guideline
Inspector provides the current status of LWFObject instances
Pros
Cons
LWF Converter (swf2lwf.rb) expects JSON (Hash) Data Format
$ ruby swf2lwf.rb foo.swf foo_atlas.json
ResourceCache (lwf_unity_resourcecache.cs) does the best for it
Return the same material as possible with caching the resouces
Implement TextureLoader and pass it through LWFObject Load method or SetLoader method
Reference: LWFObject.cs
How about SkinnedMeshRenderer instead of MeshRenderer?
It seems that CPU matrix calculation is a little bit better than SkinnedMeshRenderer.
Pros
Cons
LWF decides to use a text renderer by the font name at the runtime
A: Use SetText API
$ macruby fontconv.rb MTLmr3m.ttf MotoyaLMaru 17 "" 2048 2048 MTLmr3m
/*
* Connect LWF to SystemFontRenderer
*/
LWF.UnityRenderer.ISystemFontRenderer.SetConstructor(() => {
return new SystemFont.Renderer();
});
We want to integrate it as soon as possible! But
We need automatic line feed...
LWF works fine with NGUI!
UIWidget inherited class for LWF
Embedded LWF Runtime for HTML5 with Canvas Renderer
If it is available at the runtime
CSS3 3D | Canvas | |
---|---|---|
Android 2.x-3.x | - | - |
Android 4.x- | - | GPU |
iOS 4.x | GPU | - |
iOS 5.x- | GPU | GPU |
In our experience, Canvas is more stable and faster than CSS3 in every platform, however, of course it may vary by animation data
LWF.useCanvasRenderer();
cache = LWF.ResourceCache.get();
Canvas Renderer does not change the Canvas context as possible for the performance
LWF.useWebkitCSSRenderer();
cache = LWF.ResourceCache.get();
CSS3 Renderer does not change the CSS style of DOM elements as possible for the performance
LWF.useWebGLRenderer()
cache = LWF.ResourceCache.get();
Experimental Implementation, but it would work correctly
Loading LWF binary data using ArrayBuffer, better than the below
LWFLoader.prototype.readByte = function() {
return this.d.charCodeAt(this.index++) & 0xff;
};
LWFLoader.prototype.readChar = function() {
return String.fromCharCode(this.readByte());
};
Asynchronous Loading LWF binary data
ResourceCache loadLWF and loadLWFs support it
Retina-ready text rendering in those renderers!
A: Use setText API as well as LWF Runtime for Unity
Write JavaScript code in the action panel of Adobe Flash, and then it works on LWF as well as ActionScript of Flash Player
JavaScript code should be in the /* js comment block
/* js
this.gotoAndPlay("run");
*/
/* js
this.mc.x += 10;
this.mc.y += 15;
*/
similar to CreateJS
$ ruby swf2lwf.rb -f foo.fla foo.swf
Generates foo.lwf and foo.js
/* js
frame action
*/
/* js_load
as "on (load)"
*/
/* js_postLoad
as "on (load)"
*/
/* js_enterFrame
as "on (enterFrame)"
*/
/* js_unload
as "on (unload)"
*/
_root
+mcA
+mcB
Execution order for above movieclips hierarchy
V _root js_load action only at first time
V mcA js_load only at first time
V mcA onClipEvent(load) only at first time
V mcB js_load only at first time
V mcB onClipEvent(load) only at first time
V mcB js_postLoad only at first time
V mcB frame action/js
V mcB js_enterFrame action
V mcB onClipEvent(enterFrame)
V mcA js_postLoad only at first time
V mcA frame action/js
V mcA js_enterFrame action
V mcA onClipEvent(enterFrame)
V _root js_postLoad action only at first time
V _root frame action/js
V _root js_enterFrame action
"this" is the Movie instance where the JavaScript is written on
/* js
this.gotoAndPlay("run");
*/
You can use "_root" as well as ActionScript
/* js
_root.character.gotoAndPlay("run");
*/
LWF for HTML5 includes the modified version of https://github.com/sole/tween.js/
this.addTween()
.to({x: 360, y: 80, rotation: 359}, 120)
.delay(30)
.easing(Tween.Easing.Elastic.InOut);
Yes! LWF for HTML5 works on cocos2d-html5!
var cache = LWF.ResourceCache.get();
cache.loadLWFNode({
lwf:"foo.lwf",
prefix:"res/lwf/",
fitForHeight:true,
onload:function(lwfNode) {
parentNode.addChild(lwfNode);
}
});
cc.LWFNode is a class that is derived from cc.Node class, like LWFObject of LWF for Unity
LWF for cocos2d-html5 works on JSB! But experimental
See test.coffee
LWFS: https://github.com/gree/lwfs
A Preview Tool, is a daemon that generates AUTOMATICALLY lwf files from swf/fla files as soon as these files are modified
Embedded LWF Runtime for HTML5 with Canvas Renderer
Use a spacebar or arrow keys to navigate