JSFiddle - React, Tailwind, and code Playground
by espace3d
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.1/phaser.min.js"></script>
JavaScript
object_physics = function(game,posx,posy,im){
Phaser.Sprite.call(this,game,posx,posy,im)
this.enableBody=true
game.physics.arcade.enable(this)
this.body.velocity.y=10
game.add.existing(this)
}
object_physics.prototype = Object.create(Phaser.Sprite.prototype)
object_physics.prototype.constructor = object_physics
///////////////////////////////inheritance but fail
sprite_transfert=function(game,posx,posy,im){
object_physics.call(this,game,posx,posy,im)
}
sprite_transfert.prototype=Object.create(object_physics.prototype)
sprite_transfert.prototype.constructor=object_physics
////////////////////////////////////////////////////////
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.image('head','https://s16.postimg.org/x73803eph/1_freepik.jpg');
game.load.image('icon','https://s22.postimg.org/xxjlagwm9/icon.jpg');
}
function create() {
game.physics.startSystem(Phaser.Physics.ARCADE)
var Sprite = new object_physics(game,400,100,'head')
var Sprite2=new sprite_transfert(game,20,100,'icon')
}