JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://endlessloop.org/phaser.js"></script>
JavaScript
function preload(){
}
function create(){
this.game.stage.backgroundColor = '#fff';
hero = game.add.sprite(0,0, 'hero', 'hero');
// Let's make the body twice as tall...
// For some reason the height of the head will also change!
hero.height = 64;
console.log(hero.height);
head = game.add.sprite(0, -hero.height, 'hero', 'hero');
// After that try to change the size of the head... This will change the size of the body!
head.width = head.height = 32;
emitter = game.add.emitter(0,0, 500);
game.physics.enable(emitter, Phaser.Physics.ARCADE);
emitter.makeParticles('particle');
emitter.setAll('width', 4);
emitter.setAll('height', 4);
// Here we add the children to each sprite
hero.addChild(head);
head.addChild(emitter);
game.physics.enable(hero, Phaser.Physics.ARCADE);
hero.body.collideWorldBounds = true;
hero.body.bounce.set(0.2);
hero.body.gravity.set(0, 180);
emitter.start(false, 4000, 15);
game.input.onDown.add(function(){
hero.body.velocity.x = 100;
});
game.input.onUp.add(function(){
hero.body.velocity.x = 0;
});
}
function update(){
}
function render(){}
var game = new Phaser.Game(200, 200, Phaser.AUTO, 'anger', {preload: preload, create: create, update:update, render: render});