【问题标题】:Set certain position of FlxSprite's loadgraphic method设置 FlxSprite 的 loadgraphic 方法的某个位置
【发布时间】:2015-06-05 06:07:28
【问题描述】:

我有一个 122 * 16 的图像。 它有七种颜色,我每块只用一种颜色。

但是,FlxSprite 类中的loadGraphic() 只使用widthheight

如何使用图片的特定位置?

比如我选0,loadGraphic()取位置宽,高(0到15,16),选1,(17~31,16)

【问题讨论】:

    标签: haxe haxeflixel


    【解决方案1】:

    您可以使用动画但手动更改当前帧吗?像这样的:

    var sprite = new FlxSprite(100, 100);
    sprite.loadGraphic("assets/image.png", true, 122, 16);
    sprite.animation.add("my_animation", [0, 1, 2, 3, 4, 5, 6], 0, false);
    sprite.animation.play("my_animation", true, 0);
    //sprite.animation.paused = true;
    sprite.animation.frameIndex = 2; // The frame you want to display
    

    【讨论】:

      猜你喜欢
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      • 2016-07-10
      • 2016-03-04
      • 1970-01-01
      • 1970-01-01
      • 2018-01-01
      • 2015-04-29
      相关资源
      最近更新 更多