This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uno.animations.add('stand_front', [15], fps, true); | |
uno.animations.add('stand_right', [5], fps, true); | |
uno.animations.add('stand_back', [10], fps, true); | |
uno.animations.add('front', [1,2,3,4], fps, true); | |
uno.animations.add('right', [6,7,8,9], fps, true); | |
uno.animations.add('back', [11,12,13,14], fps, true); | |
uno.animations.play('stand_front'); //empezará viendo hacia el frente |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//creando al personaje | |
uno = game.add.sprite(game.world.width/2-16, | |
game.world.height/2-16, | |
'uno'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Física | |
game.physics.arcade.enable(uno); | |
uno.collideWorldBounds = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cursores = game.input.keyboard.createCursorKeys(); | |
if(cursores.left.isDown) { | |
lastDirection = 'left'; | |
uno.scale.x = -1; | |
uno.body.velocity.x = -1*velocity; | |
uno.animations.play('right'); //uno.scale.x=-1 hace que right se voltee a left | |
} else if (cursores.right.isDown) { | |
lastDirection = 'right'; | |
uno.scale.x = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cursores = game.input.keyboard.createCursorKeys(); | |
if(cursores.left.isDown) { | |
... | |
} else if (cursores.right.isDown) { | |
... | |
} else if (cursores.up.isDown) { | |
uno.body.velocity.y = -1; | |
uno.animations.play('front') | |
lastDirection = 'front'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function move_x(alguien, dir) { | |
alguien.scale.x = dir; | |
alguien.body.velocity.x = dir*velocity; | |
lastDirection = 'right'; //right will be flipped if left | |
} | |
function move_y(alguien, dir) { | |
uno.body.velocity.y = dir*velocity; | |
if (dir > 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function update() { | |
game.physics.arcade.collide(uno, walls); | |
cursores = game.input.keyboard.createCursorKeys(); | |
uno.animations.play('stand_' + lastDirection); // importante!! "uno" se queda quieto. | |
if(cursores.left.isDown) { | |
lastDirection = 'left'; | |
uno.scale.x = -1; | |
uno.body.velocity.x = -1*velocity; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Cat = { // this is actually an object: a "prototype" object | |
color: 'none', | |
size: 'none', | |
meow: function() { | |
console.log("meow"); | |
} | |
}; | |
var Garfield = Object.create(Cat); // this is a prototype object too |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun comment-marked-region () | |
"comments the marked region, just like M-x comment-region" | |
(interactive) | |
(comment-region (mark) (point))) | |
(defun uncomment-marked-region () | |
"uncoments the marked region, just like M-x uncomment-region" | |
(interactive) | |
(uncomment-region-default (mark) (point))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = (function () { | |
this.x = 100; | |
var a = 1; | |
var showX = function () { | |
console.log(this.x); | |
}; | |
var setX = function () { | |
this.x = -100; |