【问题标题】:Resize a Sprite image in Haxe?在 Haxe 中调整 Sprite 图像的大小?
【发布时间】:2013-05-08 05:04:56
【问题描述】:

我正在使用 Haxe 和 box2d 开发一个小游戏。我正在重新缩放作为球体的玩家身体,而玩家与特定对象接触,但我试图在缩放身体时缩放图像。

public function new(w:Int, x:Int, y:Int) 
{
    super();
    this.w = w; 
    this.x = x; 
    this.y = y;
    var imgSprite = new Sprite();
    imgSprite.addChild(new Bitmap(Assets.getBitmapData("img/ball.png")));
    imgSprite.x = -w;
    imgSprite.y = -w;
    this.addChild(imgSprite);
    this.alpha = .5;
    contactList = new Array<B2Body>();
    makeBody(w, x, y, 0);
}

public function resize(w:Int, x:Int, y:Int)
{
    var tempAngle = this.body.getAngle();
    Main.World.destroyBody(this.body);
    makeBody(w, x, y, tempAngle);
}

据我所知,没有任何内容可以轻松缩放图像。如何在主体旁边缩放位图?

【问题讨论】:

标签: bitmap scaling flashdevelop haxe nme


【解决方案1】:

为什么不直接扩展 imgSprite 容器?

imgSprite.scaleX = scale;
imgSprite.scaleY = scale;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-27
    • 2010-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-20
    相关资源
    最近更新 更多