裏Canvasに色々描く→toDataURL()をImageにぶっこむ→本番Canvasに描く=激烈に重い
tempCtx.clearRect(0,0,FIELD_SIZE_X,FIELD_SIZE_Y); // 地面描画 if(this.focus){ tempCtx.drawImage(class_Image["fieldTileFocus"], 0, 0, FIELD_SIZE_X, FIELD_SIZE_Y); } else { tempCtx.drawImage(class_Image["fieldTile"], 0, 0, FIELD_SIZE_X, FIELD_SIZE_Y); } // キャラ描画 if(this.character != null){ tempCtx.drawImage(class_Image["chara"+character["CharacterId"]], 0, 0, FIELD_SIZE_X, FIELD_SIZE_Y); } tempImage = new Image(); tempImage.src = tempCanvas.toDataURL(); ctx.drawImage(tempImage, this.x, this.y, this.sizeX, this.sizeY);
これは超重い。
setIntervalで一定時間ごとに実行していたら、メモリ消費が1GB行った。
// 地面描画 if(this.focus){ ctx.drawImage(class_Image["fieldTileFocus"], this.x, this.y, this.sizeX, this.sizeY); } else { ctx.drawImage(class_Image["fieldTile"], this.x, this.y, this.sizeX, this.sizeY); }
これは割と軽い。安定している。