blob: fc382f9a21a1f5578e5798b497b2d5107c380995 (
plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
|
(function(window) {
function Cat() {
this.initialize();
}
var p = Cat.prototype = new Container();
p._barrelRolling = false;
p._rollState = 0;
p._maxRollState = 0;
p._gagging = false;
p._gags = [];
p.base_initialize = p.initialize;
p.initialize = function() {
p.base_initialize();
var _this = this;
this.img = new Image();
this.img.onload = function() { _this.setup(); };
this.img.src = "cat.jpg";
};
p.setup = function() {
this.gfx = new Bitmap(this.img);
this.addChild(this.gfx);
this.regX = this.img.width / 2;
this.regY = this.img.height / 2;
}
p.tick = function() {
if (this._barrelRolling) {
this.rotation += 360.0 / this._maxRollState;
this._rollState++;
if (this._rollState >= this._maxRollState) {
this._rollState = 0;
this._barrelRolling = false;
}
}
for (i = 0; this._gags[i]; i++) {
//if (this._gags[i].escaped &&
}
}
// Starts the barrelroll if the cat's not currently rolling about
p.barrelRoll = function() {
if (!this._barrelRolling) {
this._rollState = 0;
this._barrelRolling = true;
this._maxRollState = Ticker.getFPS() * 1.5;
}
}
// Makes the cat gag
p.gag = function() {
if (!this._gagging) {
this._gagging = true;
// @todo create/shoot the gag
window.setTimeout(function(cat) { cat._gagging = false; }, 250, this);
}
}
window.Cat = Cat;
}(window));
|