zoukankan      html  css  js  c++  java
  • 使用SWFSheet把swf转换成SpriteSheet

    工具SWFSheet官方地址

    Just released a beta of SWFSheet 1.1 here: http://www.bit-101.com/blog/?p=2948 

    国内下载地址: Download

    说明:

          我早在去年十二月底就完成了SWFSheet的功能实现,直到这个周,我对他进行了完善,并准备正式发布它。

          我当时的主要想法是,把Flash创建的动画,转换成Sprite sheet的形式。关于SpriteSheet我就不多说了,你可以在google上或Wiki上找出它的详细资料。

          我当初的目的是把flash动画应用到iphone上,而且在后来开发手机游戏的时候发现,使用Flash来制作动画仍是最好的方式。Flash拥用强大的时间轴,简单易用的画图工具、补间、3D,还有强大的脚本功能AS2/AS3。然而,把一个漂亮的Flash动画转换成 能被cocos2d 直接使用在IPhone/IPad上 或 被XNA使用在Windows Phone 7上,都不是一件容易的事。我曾经手动来实现过一段时间,真TMD太不给力了。如此以来,SWFSheet就应运而生。

         SWFSheet是一款AIR程序,在Windows和MAC上都通过了测试。你可以使用 你想用的任意方式来创建Flash动画,无论是Flash cs5(或旧版本)、Flex/Flash builder,还是其它方式来生成swf动画,都无所谓。只要你能把swf导入到SWFSheet就行了。

       把swf导入之后,你立即就能看到,动画出现在SWFSheet上的左上区块里。SWFSheet会从该动画的 所有帧中的 指定数量的帧中捕获图像,并把它们以网格的形式排列在Bitmap上。至此,你就可以 使用SpriteSheet技术方式来驱动这个Bitmap 使它动起来。你可以调整你要捕获的帧数,使动画更平滑;你也可以调整每一帧的要捕获的区域,来最大化利用Bitmap的空间;如果Bitmap的空间不足以捕获指定的所有帧,你可以使用一个大一点的Bitmap.有任何设置的改变,都要求你点击“Capture ”来重新捕获。

       通常情况下,脚本动画onEnterFrame 之类的循环中,会有各种各样的变化。有时候这会产生一些小故障,比如说在第一次onEnterFrame 触发之前捕获了第一张图像,而这时还没有对动画的转变 进行初始化。别担心,SWFSheet里有“Skip first frame”的复选框,用来处理这种情况。也有一些针对平滑处理的设置,可能会、也可能不会对一些特殊的动画或transparency产生作用。默认情况下,从swf中加载的动画的背景是透明的,但是你可以重新设置一个你想要颜色的不透明的图像作为背景。你也可以改变动画的预览帧频,当然这不会改变Bitmap,但能让你看到不同帧频下的动画效果,以便你进行帧频的选择。

       有一个要注意的地方,对bitmaps 的大小有一个限制。当我们使用2的n次方(power of two)作为正方形Bitmap的尺寸(像64*64,128*128,256*256)时,我们可以利用额外的优化方式,在这里,这种尺寸是唯一的选择。不过如果有足够多的人要求自定义尺寸的话,我会在将来的版本中实现它。

        AIR程序安装包:http://www.bit-101.com/swfsheet/SWFSheet.air

        入门测试文件:http://www.bit-101.com/swfsheet/swfsheet_test_files.zip

    //---------------------------------------------------------------------------------

    SWFSheet Version 1.1 beta

    Jan 12 2011 Published by keith under FlashGeneral

    It snowed here in Boston on Wednesday. Enough that I didn’t make it out of the house. Or at least not out of the driveway with shovel in hand. So, with a day off, I worked on adding features to SWFSheet. From yesterday’s post, I successfully implemented features 1-3. To recap and expand:

    1. PNG Sequence Export. Click on the new button “Export PNG Sequence” and a small window will pop up. Here you can enter the prefix to save the files with (“frame_” by default), and browse to a directory to store them.

    2. Custom Sprite Sheet Sizes. There’s a new radio button in the size section, called “Custom”. There’s also a button there that will pop up another small window allowing you to set the size of the custom sprite sheet size, up to 4096×4096. Nuff said.

    3. MetaData Saving. Click the Save MetaData button and yet another small window will open. This has a group of radio buttons allowing you to choose an export format. The first is the Zwoptex xml/plist format used by cocos2d. Then the Corona format, which should save in a format defined here. There’s a generic XML format I created, and the Sparrow format, which is essentially the same with slightly different names, and a raw text format that is just a comma-delimited, one-frame-per-line text dump of x,y,w,h.

    As I write this, a few people are testing the new build, and so far so good. But I’m releasing this as a beta, just as a warning that the new stuff may not be thoroughly tested – particularly the export formats. In fact, they might not be tested at all. So try them out and let me know if you run into any issues and I’ll correct them ASAP.

    As for more advanced texture packing, I’ve pretty much decided against doing anything on this. I’ve had a couple of offers to share code or collaborate on packing algorithms, but I think I’m going to decline. For one, there are already some great tools out there that do a good job of this. Zwoptex as I’ve mentioned, and also TexturePacker. It would take a LOT of work on my part to come close to what they do in that regard. They also do stuff like PVR generation, and multiple bitmap formats, dithering, transparency masking, etc. So I’m not going to bother trying to compete with these products, but do something that works well with them.

    The other point is that with the new PNG Sequence Export feature, SWFSheet will work in conjunction with these or any other tools wonderfully. Load your sprite, set the frame, number of frames, etc. and export a PNG sequence. Load that into one of these other tools and pack away. This doesn’t belittle the value of SWFSheet at all. Those other tools cannot make sprite sheets from SWFs. And there’s no good way to get image sequences out of Flash, so they complement each other perfectly.

    You might be saying to yourself, “but Flash already has an image sequence exporter.” But if you’re saying that, you’ve never actually tried to use it. It’s virtually useless. Yes, it will export a sequence of the frames on the main timeline. But what if you have animations in nested clips? Nope. Animations set up with code on enterFrame events? Nah. Timer-based animation? Tween libraries? Forget about it! SWFSheet will export PNG sequences from all those without a problem. In fact, the more I thought about it, the more I realized that the PNG Sequence Export is really a pretty awesome feature all by itself.

    So here for your pleasure, is SWFSheet 1.1 beta. Use it, abuse it, give me feedback.

  • 相关阅读:
    ftp 下载最近一小时的文件
    hdu4767 Bell——求第n项贝尔数
    Uva11762 Race to 1——有向无环图&&记忆化搜索
    P3232 [HNOI2013]游走——无向连通图&&高斯消元
    Random Walk——高斯消元法
    B君的历史——复数乘法&&爆搜
    复数快速幂【模板】
    UVa11542Squre——异或方程组&&高斯消元法
    UVa10828 Back to Kernighan-Ritchie——概率转移&&高斯消元法
    高斯消元法【模板】
  • 原文地址:https://www.cnblogs.com/afly/p/2356155.html
Copyright © 2011-2022 走看看