HTML and CSS Reference
In-Depth Information
Q.Player = Q.Sprite.extend({
init:function(props) {
this._super(_(props).extend({
sheet: 'man',
sprite: 'player',
rate: 1/15,
speed: 250,
standing: 3,
type: 4,
health: 100,
collisionMask: 1,
direction: 'right'
}));
this.add('animation, 2d')
.collisionPoints({
top: [[ 20, 3]],
left: [[ 5,15], [ 5,40]],
bottom: [[ 20,51 ]],
right: [[ 30,15], [ 30,40]]
});
this.bind('animEnd.fire_right',this,"launchBullet");
this.bind('animEnd.fire_left',this,"launchBullet");
this.bind('hit.tile',this,'tile');
Q.input.bind('fire',this,"fire");
Q.input.bind('action',this,"jump");
},
fire: function() {
this.play('fire_' + this.p.direction,2);
},
damage: function(amount) {
this.p.health -= amount;
if(this.p.health < 0) {
Q.stageScene("level",0,Q.PlatformStage);
}
},
launchBullet: function() {
var p = this.p,
vx = p.direction == 'right' ? 500 : -500,
x = p.direction == 'right' ? (p.x + p.w) : p.x;
this.parent.insert(new Q.Bullet({ x: x, y: p.y + p.h/2, vx: vx
}));
},
Search WWH ::




Custom Search