随机闪烁仅发生在Galaxy Note 4上

时间:2015-09-05 23:09:31

标签: java android android-canvas samsung-mobile galaxy

出于某种原因,我发现了一个根本没有意义的故障,只出现在Galaxy Note 4上,正如我现在想的那样。我唯一的测试设备是Nexus 7(2012),蓝色堆栈beta和Note 4.这个小故障只出现在注释4上。这是绘图代码:

if(!started){
            continue;
        }
        h = getHolder();
        if (!h.getSurface().isValid()){
            continue;
        }
        Canvas c = h.lockCanvas();
        c.drawRect(0, 0, this.getWidth(), this.getHeight(), white);

        //draw walls
        for(int i=0;i<walls.length;i++){
            c.drawRect(walls[i].x, walls[i].y, walls[i].bottom, walls[i].right, red);
        }

        //draw portals
        for(int i=0;i<portals.length;i++){
            Log.d("S", i+"");
            Log.d("S", portalimages[i].toString());
            c.drawBitmap(portalimages[i], portals[i].x1, portals[i].y1, null);
            c.drawBitmap(portalimages[i], portals[i].x2, portals[i].y2, null);
        }

        //draw startlocations
        for(int i=0;i<startlocations.length;i++){
            c.drawBitmap(player, startlocations[i].x, startlocations[i].y, null);
        }

        //draw checkpoints
        for(int i=0;i<checkpoints.length;i++){
            c.drawRect(checkpoints[i].x, checkpoints[i].y, checkpoints[i].x+this.getHeight()/18, checkpoints[i].y+this.getHeight()/18, blue);
        }

        //draw middle line
        c.drawRect(0, getHeight()/2-getHeight()/80, getWidth(), getHeight()/2+getHeight()/80, black);

        menu.draw(c);

        h.unlockCanvasAndPost(c);

一旦调用onClick,就会出现故障。它只是增加了一个新的起始位置:

startlocations[location] = new Coord(lastx, lasty);
if(location>0){
    location = 0;
}else{
    location++;
}
break;

注意:使用startlocations = new Coord[2];

设置startlocations

对不起视频质量。注4是我的爸爸,所以我不得不通过消息服务发送它并将其压缩,然后YouTube压缩它更多。然后它突然出现:https://www.youtube.com/watch?v=Ig9mflYBPaI

点击播放器开始位置按钮时没有任何其他变化。我会尝试更多地考虑这个,但我决定在这里发布,以防我错过了什么。谢谢!

修改

我现在知道当你没有这条线时问题会消失:c.drawBitmap(player, startlocations[i].x, startlocations[i].y, null);这没有任何意义。没有错误,它加载了此代码。 BitmapFactory.decodeResource(getResources(), R.drawable.portal);及更高版本使用Bitmap.createScaledBitmap(player, this.getHeight()/18, this.getHeight()/18, true);

进行调整

1 个答案:

答案 0 :(得分:0)

我找到了答案,根本没有任何意义。出于某种原因,就在这个类中,图像需要具有透明度,否则会出现故障。后来我画了其他非透明图像。它没有任何意义,但它的工作原理。如果你知道发生这种情况的原因,请告诉我。

我的猜测是,在另一个类中我使用了主包,但在这个类中它是一个不同的包。这可能是它只是这个类(或方法)的原因。我将不得不做更多的测试。

感谢。