For some reason I have found a glitch that makes no sense at all and only appears on the Galaxy Note 4, as I think now. The only test devices I have is a Nexus 7 (2012), blue stacks beta and the Note 4. This glitch only is appearing on the note 4. Here is the drawing code:
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);
The glitch happens once my onClick is called. it just adds a new startlocation:
startlocations[location] = new Coord(lastx, lasty);
if(location>0){
location = 0;
}else{
location++;
}
break;
Note: startlocations is setup with startlocations = new Coord[2];
Sorry for the video quality. The Note 4 is my Dad's so I had to send it over a messaging service and it compressed it, then YouTube compressed it more. Then it breaks out into this: https://www.youtube.com/watch?v=Ig9mflYBPaI
There is nothing else that changes on click of the player start locations button. I will try to look more into this but I decided to post it here in case I missed something. Thanks!
Edit:
I now know that the problem goes away when you do not have this line : c.drawBitmap(player, startlocations[i].x, startlocations[i].y, null);
which makes no sense. There is no error and it is loaded with this code. BitmapFactory.decodeResource(getResources(), R.drawable.portal);
and later is adjusted with Bitmap.createScaledBitmap(player, this.getHeight()/18, this.getHeight()/18, true);