• Content Count

  • Joined

  • Last visited

About wclarkson

  • Rank

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location

Recent Profile Visitors

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

  1. wclarkson

    Phaser 3 : set timer event one more time after fireing

    Here is how I build a clock for games. I hope this is what you mean: var myClock=new Clock({scene:this,secs:60}); class Clock extends Phaser.GameObjects.Container { constructor(config) { super(config.scene); this.scene = config.scene; if (!config.secs) { this.secs = 60; } else { this.secs--; } if (!config.style) { config.style={fontSize:game.config.width/10,color:'#27ae60',align:'center'}; } this.text1=this.scene.add.text(0,0,"",config.style).setOrigin(0.5,0.5); this.add(this.text1); this.scene.add.existing(this); this.setText(); this.setSize(this.text1.displayWidth,this.text1.displayHeight); ut.emitter.on(G.CLOCK_START,this.startClock,this); ut.emitter.on(G.CLOCK_STOP,this.stopClock,this); } startClock() { console.log("startClock"); this.timer = this.scene.time.addEvent({ delay: 1000, callback: this.tick, callbackScope: this, loop: true }); } stopClock() { console.log("stopClock"); this.timer.remove(); } tick() { this.secs--; if (this.secs == 0) { // this.stopClock(); } this.setText(); } setText() { var mins = Math.floor(this.secs / 60); var secs = this.secs - (mins * 60); secs=this.leadingZeros(secs); mins=this.leadingZeros(mins); this.text1.setText(mins+":"+secs); } leadingZeros(num) { if (num < 10) { return "0" + num; } return num; } }
  2. wclarkson

    Adding HTMLelements

    I haven't written the part for dropdowns yet, but here is the part on textInput https://phasergames.com/phaser-3-input-text-form-ui-part-1/
  3. wclarkson

    Phaser 3 : set timer event one more time after fireing

    Then just create a one-shot timer everytime you'd like to use it. If it is a clock that you want to simulate, set up a function to fire every second, and use a boolean to return out of the function if your clock is 'off'
  4. wclarkson

    Phaser 3 : set timer event one more time after fireing

    Set the loop property to true. If you want it to run X number of times, set up a counter and then remove the timer when the counter gets to X; this.time.addEvent({ delay: secs, callback: myfunction, callbackScope: this, loop: true }); https://phasergames.com/phaser-3-snippets/phaser-3-time-snippets/
  5. wclarkson

    how do i can create InputField in phaser 3

    This response is probably a bit late to be of help to you, but I had the same problem. This is what I came up with. https://phasergames.com/phaser-3-input-text-form-ui-part-1/
  6. wclarkson

    Cant get group to work

    try group.children.getArray().forEach
  7. wclarkson

    Rounded Rectangle

    Yes, I did see that turn up the other day on something. Great that it was added.
  8. wclarkson

    Positioning GameObjects on an auto scale game

    I agree with Antriel about placing thing relative. This is the method I'm using https://phasergames.com/scaling-games-in-phaser-3/
  9. wclarkson

    Rounded Rectangle

    Thanks! Yeah, it does seem like quite a bit for what used to be one line of code. I will take your function and try to adapt it to what I was doing. I wound up using a rectangle with two circles of the same color in the end to make a pill button.
  10. wclarkson

    Help with simple code with ES6 and phaser 3

    I wouldn't try importing the Phaser library. Just link it in the HTML file and you'll be good to go.
  11. wclarkson

    Help with accessing a containers children

    Log out your container to the console this.input.on('pointerdown', function(container){ console.log(container); }); That will give you a list of all the properties and children.
  12. wclarkson

    Help with accessing a containers children

    What you are looking for is container.list[0] and container.list.length. It is a bit confusing as so many other things use children.
  13. wclarkson

    Rounded Rectangle

    I'm finding the graphics examples very impressive, but it is the simple things that are tripping me up. I know I must be missing something simple, but is there a simple way to draw a rounded rectangle in Phaser 3?
  14. wclarkson

    Container Height and Width

    Hi, Yeah I found setting the .width does nothing as well. However, in the code example above I am setting the displayWidth of the container. This is my console.log of a class that extends container. Changing it will alter the width of the container. Grid {_events: r, _eventsCount: 0, scene: SceneMain, type: "Container", parentContainer: null, …} active:true alpha:(...) alphaBottomLeft:(...) alphaBottomRight:(...) alphaTopLeft:(...) alphaTopRight:(...) angle:(...) blendMode:(...) body:null cameraFilter:0 data:null depth:(...) displayHeight:(...) displayOriginX:(...) displayOriginY:(...) displayWidth:240 Thanks for the links on the width vs displayWidth. Still wrapping my head around it.
  15. wclarkson

    Container Height and Width

    It makes more sense now that you explain it. I'm just so used to having height and width so readily available on all objects. Can you tell me what is the difference between width and displayWidth?