1

我是 Flixel 的新手,所以如果我的问题太简单,请原谅我。

我的问题是:我使用 Photoshop 制作了四个非常简单的图像(站立、移动、侧立、侧移),然后将其传递给 Texture Packer(样式表制造商)它为我生成了一个图像(非常简单)加上一个 JSON文件,这里是:http:
//i.stack.imgur.com/UTi4G.png
所以我想将它们与 Flixel 一起用作站立的角色(第一个),当我调用动画移动时,它将使用最后一张图片,但它没有按预期工作。基本上它一次显示所有四个图像。
这是代码:
Character.as:

package
{
    import org.flixel.FlxSprite;

    public class Character extends FlxSprite
    {
        [Embed (source="character.png")]
        private var CharacterGraphic:Class;
        public function Character(X:Number=0, Y:Number=0)
        {
            super(X, Y);
            loadGraphic(CharacterGraphic, true, false, 53, 54);
            velocity.y = 100;
            addAnimation('move_forward', [0, 3], 30, false);

        }

    }
}

PlayState 类(我在其中创建此类的实例)

    override public function create():void{
        character = new Character(100, 200);
        add(character);

    }
    override public function update():void{
        //for debugging
        if(character.y == 600){
            character.play('move_forward');
        }
        super.update();
    }

所以我期望:
当velocity.y为600(仅用于测试)时,第一个图像被弹出(并继续下降)move_forward动画开始(循环通过第一个和最后一个图像)

输出是:
所有四个图像都弹出,当velocity.y == 60 时没有任何反应。

我真的认为我遗漏了一些东西,因为我对 Actionscript 3 和 Flixel 非常陌生(也是游戏开发!)。

几乎相同的步骤适用于在线教程,唯一的区别是他创建了几个动画(敌人)而不是一个,在这里查看http://gotoandlearn.com/play.php?id=139
对于 JSON 文件,我从来没有找到了它的用途(我尝试在 IRC 频道中询问,但没有人提及),也在论坛/教程中。

4

1 回答 1

1

我看到的第一个问题是您的图像位于多行上。Flixel 喜欢它的框架都是在一个水平行中的正方形。即使您为每个框架指定一个矩形大小,它们仍然需要全部相同大小并且在一个水平行中。如果你做对了,你应该有 0 到 3 帧。

当您的图像/框架应该更改时没有发生任何事情的原因是因为您希望它更改为的索引处没有框架。这应该通过相同的更改来解决。

由于这个原因,我不相信大多数 sprite 打包器都有 flixel 项目。Sprite 打包器正在尝试最小化文件大小,因此他们会将尽可能多的 sprite 塞入尽可能小的空间,因此每个 sprite 的大小都与其他 sprite 不同。正如我所说,Flixel 喜欢它的精灵大小相同且全部排成一排。

I found one that does do what I want it to...I'll have to take a look once I get home to see what program it is (or if I don't even have it any more). In the mean time, just use photoshop to make a document the height of your tallest sprite and the width the width of your widest sprite x the number sprites in the sheet. Then place each sprite/frame in the appropriate space.

Edit: I don't think you need the JSON file at all. Just use a transparent PNG.

于 2012-04-12T18:17:23.870 回答