espace

Members
  • Content count

    419
  • Joined

  • Last visited

About espace

  • Rank
    Advanced Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. hi, i would work with separate files. the problem, i create my sprite config before and i would access the game.height to put them correctly in the screen. minimum example code //parameter.js var circle; var circle2; //proto.js before main.js var create_circle=()=>{ circle = game.add.graphics(0, 0); circle.beginFill(0xFF0000, 1); circle.drawCircle(300, game.height*.3, 100); } //main.js var config = { width: 800, height: 800, renderer: Phaser.CANVAS, antialias: true, multiTexture: true, state: { preload: create, update: update }, } let game = new Phaser.Game(config); var circle; function create () { this.game.scale.pageAlignHorizontally = true; this.game.scale.pageAlignVertically = true; this.game.scale.refresh(); circle2 = game.add.graphics(0, 0); circle2.beginFill(0xFF0000, 1); //HERE IT'S EASY circle2.drawCircle(300, game.height*.3, 100); // HERE IT DON'T WORK AND IT'S NORMAL BECAUSE GAME DON'T EXIST //BUT IS THERE A WAY TO ACCESS GAME.HEIGHT ??? //window.innerHeight is not the same than game.height ! create_circle() } function update () { }
  2. Why don't you create differents states corresponding to your two games ? Eg: Boot_1 Boot_2 Or Boot[0] and Boot[1] I use a parameter.js who stock the variables and parameters at the first position in my index.html. Like this, all my states have access to this data. When is possible I avoid the use of "this" (ambiguous) and prefer object parameter => it's powerfull. Have you understood ? (Not Englishmen ! ) ...
  3. espace

    Health bar Plugin doesn't upgrade its position

    Have you test it ? Normally marks it as solved, it's helpful for the others who search the same thing.
  4. espace

    can't do phaser button prototype

    find by myself: _bu = function (p) { Phaser.Button.call(this,p.g,p.x,p.y,p.image,p.callback,this,0,0,0); p.a != null ? this.alpha = p.a : this.alpha = 1 p.v != null ? this.visible = p.v : this.visible = true p.anchorx != null ? this.anchor.x = p.anchorx : this.anchor.x = .5 p.anchory != null ? this.anchor.y = p.anchory : this.anchor.y = .5 p.flag != null ? this.flag = p.flag : this.flag = "undefined" game.add.existing(this) }; _bu.prototype = Object.create(Phaser.Button.prototype); _bu.prototype.constructor = _bu
  5. hi, i success to make a simple button like the example in the doc, but when i try to make a button prototype it don't works. i receive no error and i can't see my button. But in the console i see my object button, visible on true etc.... _bu = function (p) {//parameter Phaser.Button.call(this, p.g, p.x, p.y, p.image,p.callback,this,0,0,0); p.a != null ? this.alpha = p.a : this.alpha = 1 p.v != null ? this.visible = p.v : this.visible = true p.anchorx != null ? this.anchor.x = p.anchorx : this.anchor.x = .5 p.anchory != null ? this.anchor.y = p.anchory : this.anchor.y = .5 p.flag != null ? this.flag = p.flag : this.flag = "undefined" }; _bu.prototype = Object.create(Phaser.Button.prototype); _bu.prototype.constructor = _bu var coucou =()=>{console.log("coucou")} var interface={}; interface.restart_p = { g: game, image: "restart", x: 1400, y: 400, v: true, callback : coucou, } interface.restart = new _bu(interface.restart_p) an idea ?
  6. espace

    Invisalign - Soccer Game

    Strange...but cool
  7. espace

    overall loss of quality

    use bitmapfonts it's an image of your font example : https://phaser.io/examples/v2/loader/load-bitmap-font to create bitmapfonts with an existing font : http://kvazars.com/littera/
  8. thanks, in fact i yet use a similar snippet 😁 var tw=[]; var _tw //pseudo prototype var parameter ={ e: Phaser.Easing.Bounce.Out, i: 0, //number repeat y: true, //yoyo a: 0, // alpha t: 500, //time d:100, // delay r: 45, //rotation dx:100, //distance dy:200, sx:1, //scale sy:1, } _tw = (p,n) => { //parameter,number if (p.e == null) { p.e = Phaser.Easing.Linear.None } if (p.i == null) { p.i = 0 } if (p.y == null) { p.y = false } if (p.a != null) { // alpha tw[n]=game.add.tween(p.o).to({ alpha: p.a }, p.t, p.e, true, p.d, p.i, p.y); } if (p.r != null) { //rotation tw[n] = game.add.tween(p.o).to({ angle: p.r }, p.t, p.e, true, p.d, p.i, p.y); } if (p.sx != null) { //scale tw[n]= game.add.tween(p.o.scale).to({ x: p.sx, y: p.sy }, p.t, p.e, true, p.d, p.i, p.y); } if (p.dx != null) { //displacement tw[n] = game.add.tween(p.o).to({ x: p.dx, y: p.dy }, p.t, p.e, true, p.d, p.i, p.y); } tw[n].c = () => { if (p.c != null) { let time_adapted = p.d + p.t + p.ctime wait(p.callback, time_adapted) } } tw[n].p = () => { //pause tw[n].pause() } tw[n].r = () => { //resume tw[n].resume() } } _tw(parameter,0)
  9. espace

    Health bar Plugin doesn't upgrade its position

    hi, See my files attached (test_bar.zip), it works. Just open the index.html file and drag the circle and the healtbar follow the circle. Have a good day. var config = { width: 800, height: 800, renderer: Phaser.CANVAS, antialias: true, multiTexture: true, state: { preload: create, update: update }, } let game = new Phaser.Game(config); var circle; var bar; function create () { this.game.scale.pageAlignHorizontally = true; this.game.scale.pageAlignVertically = true; this.game.scale.refresh(); circle = game.add.graphics(0, 0); circle.beginFill(0xFF0000, 1); circle.drawCircle(300, 300, 100); // Input Enable the sprite circle.inputEnabled = true; // Allow dragging circle.input.enableDrag(); //healthbar var bar_config = { width: 250, height: 40, x: 200, y: 400, bg: { color: '#Fff828' }, bar: { color: '#FEFF03' }, animationDuration: 200, flipped: false }; bar = new HealthBar(this.game, bar_config); //here you discover the properties of bar => HealthBar and you see sub-sprites like barSprite, bgSprite and others ... // in dev. tools on chrome and firefox also, just type bar in the console console.log(bar) } function update () { bar.bgSprite.x=circle.x bar.bgSprite.y=circle.y bar.barSprite.x=circle.x bar.barSprite.y=circle.y } test_bar.zip
  10. espace

    Health bar Plugin doesn't upgrade its position

    Read these doc : https://github.com/bmarwane/phaser.healthbar/blob/master/README.md And try : this.myHealthBar = new HealthBar(this.game, {x: 200, y: 200, width: 120}); this.update=()=>{ this.myHealthBar.x=this.x //Try maybe this also //this.myHealthBar.x=this.body.x }
  11. espace

    Health bar Plugin doesn't upgrade its position

    Hi, you must put the healthbar position in the update function on your enemy to follow the enemy x and y position.
  12. hi, i would use tween with an object parameter...how do you do ? function create() { var sprite = game.add.sprite(0, 0, 'phaser'); var config={ properties : { sprite, x:100, } duration : 1000, ease : Phaser.Linear.none, autoStart : true, delay:10, repeat : 0, yoyo:false } game.add.tween(config) }
  13. espace

    how to do this effect ?

    Solved thanks. Have a good day
  14. espace

    Cannot have " this" in prototype

    ok but why ?