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 Game(){ | |
/* | |
Then in your gamestate.create you add a Phaser.Signal | |
with which you can dispatch events: | |
*/ | |
var lizardman, | |
eventChannel = new Phaser.Signal(); |
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 Lizardman(game, x, y, sprite){ | |
this.game = game; | |
Phaser.Sprite.call(this, game, x, y, sprite); | |
this.game.add.existing(this); | |
this.game.physics.enable(this, Phaser.Physics.ARCADE); | |
this.anchor.setTo(0.5, 0.5); | |
} |
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 Lizardman(game, x, y, sprite){ | |
this.game = game; | |
Phaser.Sprite.call(this, game, x, y, sprite); | |
this.game.add.existing(this); | |
this.game.physics.enable(this, Phaser.Physics.ARCADE); | |
this.anchor.setTo(0.5, 0.5); | |
} |
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 MODEL = (function(m){ | |
m.num = 10; | |
return m; | |
}(MODEL || {})); | |
var UI = (function(ui, model, setter){ | |
ui.public = setter; | |
ui.DOM = (function(){ | |
var priv = model.num * ui.public; | |
return{ |
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
@-webkit-keyframes popIn { | |
0% { opacity: 0; transform: scale(.3);} | |
100% { opacity: 1; transform: scale(1);} | |
} | |
@keyframes popIn { | |
0% { opacity: 0; transform: scale(.3);} | |
100% { opacity: 1; transform: scale(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
var ptor = protractor.getInstance(), | |
driver = ptor.driver; | |
var findByName = function(name) { | |
return driver.findElement(protractor.By.name(name)); | |
}; | |
// showtime! | |
ptor.driver.get('/Test/Index'); | |
ptor.driver.findElement(protractor.By.xpath('/html/body/div/div[1]/section/input')).sendKeys('whatever'); |
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
/* | |
It's well know how to print a stack trace after catching an exception/error in Javascript. | |
But what if you are not catching anything? | |
You see something happening at a particular line in code, | |
but you want to know what's the code path through which the control flow reached that line when that interesting thing happened. | |
In other words, you want to know what's the stack trace (series of function calls, starting from beginning of the program), | |
at that particular line of code. | |
http://www.codeovertones.com/2011/08/how-to-print-stack-trace-anywhere-in.html | |
*/ |
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
/* | |
https://code.google.com/p/jslibs/wiki/JavascriptTips | |
*/ | |
function CreateTranslator(translationTable) function(s) s.replace(new RegExp([k for (k in translationTable)].join('|'), 'g'), function(str) translationTable[str]); | |
// usage: | |
var translationTable = { a:1, bb:2, b:3, c:4 }; | |
var MyTranslater = CreateTranslator( translationTable ); |
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 RandomString(length) { | |
var str = ''; | |
for ( ; str.length < length; str += Math.random().toString(36).substr(2) ); | |
return str.substr(0, length); | |
} |
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 list = [1,2,3,4,5,6,7,8,9]; | |
list = list.sort(function() Math.random() - 0.5); |
NewerOlder