espace

Members
  • Content count

    426
  • Joined

  • Last visited

Everything posted by espace

  1. hi, i have start my project with ES6 syntax, but for exporting to cocoon.io in canvas mode it must be ES5 syntax. What's the easier way to do that ? (i have try with babeljs but without success) if not i rewrite all with ES5 syntax but it's not convenient.... Another question why coding in Es6....finally is there a good benefit with mobiles games?
  2. espace

    WeChat Mini Game WIP

    Can you give a link to test it ?
  3. hi, i would have a prompt box who check different state : length of the name not the same name than the opponent but how do you do to loop this function to be sure that the player don't press ok at the final dialog box and have a name_player == null ? => see in the snippet var f={} var name_opponent=["roger","gilbert"] f.check_if_username_is_not_in_database_enemy=(st)=>{ for (var i = 0; i < name_opponent.length; i++){ return (st === name_opponent[i]) } } f.prompt=()=>{ let test = localStorage.getItem("username") if(typeof test != "string"){ name_player = prompt("Please enter your name", "Anonymous") if(name_player) { if (name_player.length < 4) { name_player = prompt("Please enter min. 4 letters", "Anonymous") } if(f.check_if_username_is_not_in_database_enemy(name_player) == true && name_player.length > 4){ localStorage.setItem("username", name_player) alert(localStorage.getItem("username")) } if(f.check_if_username_is_not_in_database_enemy(name_player) == false){ name_player = prompt("Name already exist, please choose a different name", "Anonymous") //if the player press ok the name_player === null } } } } f.prompt()
  4. hi, my game become complex and it's difficult to identify the functions who slow down my application. i have try with firefox develloper tools => performance but that don't show me my personal function ...all is phaser functions... is there a tools, a plugin for that ? thanks for your assist.
  5. Hey hey you are french ? i have already look at this but it show me phaser functions and not my personals functions... It resort often frame properties and take a lot of times but I don't know how to reduce this.
  6. Hi, I don't know how to program this effect. Imagine 20 players who hit an obstacle. At each hit, the obstacle become red with a mask and a tween to alpha 0 to 1. How do you do to have this effect (multiple hits at differents times perhaps during an instance tween) and not compromise the multiple tweens ? Thanks
  7. 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 () { }
  8. 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 ! ) ...
  9. 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.
  10. 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 ?
  11. 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
  12. espace

    Invisalign - Soccer Game

    Strange...but cool
  13. 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/
  14. 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) }
  15. 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)
  16. 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
  17. 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 }
  18. 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.
  19. espace

    how to do this effect ?

    hi, i want to make this effect depending of my picture attached below : mask_1,mask_2,mask_3,mask_final. This effect have an alpha channel ; everything that is not yellow is transparent. how do you do that ? i read the alpha_mask but i don't know how do this .... thanks for your help
  20. espace

    how to do this effect ?

    Solved thanks. Have a good day
  21. hi, i reproduce the minimal code to show what not works in my case. In this case, i would assign a new value to this in x and y. it's for the example, i could simply do cloud.x=100. why in this case my prototype don't work ? _obj = function (p) { Phaser.Sprite.call(this, p.g, p.x, p.y, p.image); p.g.add.existing(this) } _obj.prototype = Object.create(Phaser.Sprite.prototype); _obj.prototype.constructor = _obj //change the position of the sprite to x and y _obj.prototype.def = (a, b) => { console.log(this) // show window and not expected _obj ??? why ??? this.x = a this.y = b } var parameters ={ g:game, x:100, y:200, image:"cloud", } var cloud = new _obj(parameters) cloud.def(400,900) //DON'T WORKS
  22. espace

    Cannot have " this" in prototype

    ok but why ?
  23. espace

    how to do this effect ?

    hi, but how do you do to do the same effect from right to left, without move the arrow ? i would change the Phaser.rectangle.anchor but this feature is not permitted in the doc. I also change the direction of the widtharrow.width but it doesn't change the effect... have you an idea about that ? https://jsfiddle.net/dah89fnt/