Skip to content

Instantly share code, notes, and snippets.

View netcell's full-sized avatar

Nguyễn Tuấn Anh netcell

View GitHub Profile
constructor(x, y) {
...
this.isBeingDragged = false;
dragger.events.onDragStart.add(this.onDragStart, this);
dragger.events.onDragStop.add(this.onDragStop, this);
...
}
onDragStart(){
this.isBeingDragged = true;
}
class Joystick extends Phaser.Sprite {
constructor(x, y) {
super(game, 0, 0, 'background');
this.anchor.setTo(0.5, 0.5);
/* Pin indicator - what players think they drag */
this.pin = game.add.sprite(0, 0, pin);
this.pin.anchor.setTo(0.5, 0.5);
this.addChild(this.pin);
/* Invisible sprite that players actually drag */
var dragger = this.dragger = game.add.sprite(0, 0, null);
//...
, game = new Phaser.Game(properties.size.x, properties.size.y, Phaser.AUTO, 'game');
// Automatically register each state.
_.each(states, function(state, key) {
game.state.add(key, state(game));
});
//...
@netcell
netcell / gist:60097d0661ad2f74a258
Last active February 1, 2020 13:39
Camera for Phaser
var game = require('../common/game');
class Camera extends Phaser.Group {
constructor({x = 0, y = 0}) {
super(game);
var {world, physics, camera} = game;
var {centerX, centerY, bounds} = world;
this.scale.setTo(1, 1);
@netcell
netcell / abc
Created July 17, 2013 12:24
abc
abc