1

我遇到了画布、矩形和屏幕尺寸的问题:

问题

我不知道出了什么问题,因为我在两个模拟器中使用完全相同的代码,这里是代码:

云是一个简单的对象,包含图像和一些移动它们的方法,这就是我创建云的方式:

云都在一个文件中,坐标是单个云所在的矩形。

for (byte i = 0; i < 4; i++) {

        Cloud c;
        if (i == 1) c = new Cloud(5, 5, 245, 145);
        else if (i == 2) c = new Cloud(340, 30, 480, 130);
        else if (i == 3) c = new Cloud(565, 30, 725, 130);
        else c = new Cloud(830, 20, 980, 130);

        c.SetX(0);c.SetY(i * 150);


        //c.ReubicarNube();
        Clouds.Add(c);
    }

Cloud 类的构造函数调用它来处理图像(Plain 是 cloud 的超类):

public Plain(int ResourceImg, int left, int top, int right, int bottom){


    this.img = BitmapFactory.decodeResource(Init.GetContext().getResources(), ResourceImg);
    this.Width = right - left;
    this.Height = bottom - top;
    this.frameImg = new Rect(left, top, right, bottom);
    this.rect = new Rect(0, 0, this.Width, this.Height);

    Log.v("Plains", this.frameImg.toString() + " " + this.rect.toString());
}

这就是我的画法:

public void draw(Canvas canvas) {     
    canvas.drawBitmap(img, frameImg, rect, Init.PaintFilter);
    //canvas.drawbi
}

在此先感谢您的帮助!

4

1 回答 1

1

我做到了!,

我fogot将图像放在drawable-hdpi文件夹中!,这就是我不工作的原因!

谢谢!

于 2013-09-08T15:26:37.773 回答