/
Sprite_Destination.js
56 lines (49 loc) · 1.71 KB
/
Sprite_Destination.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//-----------------------------------------------------------------------------
// Sprite_Destination
//
// The sprite for displaying the destination place of the touch input.
function Sprite_Destination() {
this.initialize.apply(this, arguments);
}
Sprite_Destination.prototype = Object.create(Sprite.prototype);
Sprite_Destination.prototype.constructor = Sprite_Destination;
Sprite_Destination.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.createBitmap();
this._frameCount = 0;
};
Sprite_Destination.prototype.update = function() {
Sprite.prototype.update.call(this);
if ($gameTemp.isDestinationValid()){
this.updatePosition();
this.updateAnimation();
this.visible = true;
} else {
this._frameCount = 0;
this.visible = false;
}
};
Sprite_Destination.prototype.createBitmap = function() {
var tileWidth = $gameMap.tileWidth();
var tileHeight = $gameMap.tileHeight();
this.bitmap = new Bitmap(tileWidth, tileHeight);
this.bitmap.fillAll('white');
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.blendMode = Graphics.BLEND_ADD;
};
Sprite_Destination.prototype.updatePosition = function() {
var tileWidth = $gameMap.tileWidth();
var tileHeight = $gameMap.tileHeight();
var x = $gameTemp.destinationX();
var y = $gameTemp.destinationY();
this.x = ($gameMap.adjustX(x) + 0.5) * tileWidth;
this.y = ($gameMap.adjustY(y) + 0.5) * tileHeight;
};
Sprite_Destination.prototype.updateAnimation = function() {
this._frameCount++;
this._frameCount %= 20;
this.opacity = (20 - this._frameCount) * 6;
this.scale.x = 1 + this._frameCount / 20;
this.scale.y = this.scale.x;
};