This file contains 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 isColliding, scrollSprite, playerSprite, scrollSpeedX; | |
create: function() { | |
isColliding = false; | |
canScroll = true; | |
scrollSpeedX = 10; | |
}, | |
update: function() { | |
if(!isColliding) { | |
scrollSprite.tilePosition.x -= scrollSpeedX; |
This file contains 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 emitter = game.add.emitter(x, y, numParticles); | |
emitter.enableBody = true; | |
emitter.makeParticles('key'); | |
// try this first | |
emitter.setAll('body.mass', 0); | |
// if that doesn't work | |
emitter.forEach(function(particle) { | |
particle.body.mass = 0; |
This file contains 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 duration = 1000; | |
var context = this; | |
var timer = game.time.create(); | |
timer.add(duration, firstTimerEventCallback, context); | |
timer.add(duration * 2, secondTimerEventCallback, context); | |
timer.onComplete.add(timerCompleted, context); | |
timer.start(); |
This file contains 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
/** | |
* @author Richard Davey <rich@photonstorm.com> | |
* @copyright 2014 Photon Storm Ltd. | |
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} | |
*/ | |
/** | |
* A Rope is a Sprite that has a repeating texture. The texture can be scrolled and scaled and will automatically wrap on the edges as it does so. | |
* Please note that Ropes, as with normal Sprites, have no input handler or physics bodies by default. Both need enabling. | |
* |
This file contains 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 game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, '',{preload: preload, create: create, update:update}); | |
var rope; | |
function preload() { | |
console.log('preload'); | |
game.load.image('snake', 'assets/snake.png'); | |
} | |
function create() { |
This file contains 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
'use strict'; | |
var TouchCircle = require('../prefabs/TouchCircle'); | |
var Circle = require('../prefabs/Circle'); | |
function Play() { | |
this.bullets = null; | |
this.angle = null; | |
this.cannon = null; |
This file contains 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 Foo = function() { | |
this.message = "Hello, Foo!" | |
this.name = "Foo"; | |
// our base class | |
} | |
Foo.prototype.sayMessage = function() { | |
// an instance function | |
console.log(this.message); | |
} |
This file contains 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
'use strict'; | |
Phaser.Loader.prototype.audiosprite = function (key, urls, atlasurl) { | |
this.audio(key,urls); | |
this.json(key+'-audioatlas', atlasurl); | |
}; | |
Phaser.SoundManager.prototype.addSprite = function(key) { | |
var audioSprite = new Phaser.AudioSprite(this.game, key); | |
return audioSprite; |
This file contains 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 foo, fooDisplay; | |
foo = { | |
value: 10; | |
}; | |
fooDisplay = game.add.text(100,100,foo.toFixed(20)); | |
function update() { | |
fooDisplay.text = foo.value.toFixed(2); |
This file contains 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
objectGroup = @game.add.group() | |
map.createFromObjects "PlatformLayer", gids.PLATFORM_HORIZONTAL, "platforms", 1, true, false, objectGroup, HorizontalPlatform | |
objectGroup.callAll "isReady()" |