blackhawx

Members
  • Content Count

    24
  • Joined

  • Last visited

About blackhawx

  • Rank
    Member

Recent Profile Visitors

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

  1. blackhawx

    How do I restart scene?

    Webpack 4, phaser 3.12 Sounds like a different issue...
  2. blackhawx

    How do I restart scene?

    Your code looks very similar to to what I would for jQuery event handling on a web page. But as for Phaser event handling, perhaps the following will help... buttonGameRestart.setInteractive(); buttonGameRestart.on('pointerdown', (pointer, targets) => { this.input.addUpCallback(() => { this.scene.restart(); }, true) }); This works for me in restarting my scene, within my create() method
  3. blackhawx

    Recomendation on Tile Editing

    Hi, I'm new to Tile creation/editing for 2D games. I have spent the last week researching online on which libraries are the best for this area. Most people say that they use Tiled by https://www.mapeditor.org/ I'm not against it, but I already have Inkscape, Gimp and TexturePacker installed on my Windows machine. Can I begin my tile map journey with these installed applications? Or will I be kicking myself later in attempting to create type maps for Phaser? FYI - I do know that Phaser likes a .json file when it comes to tile maps. If this is a suitable direction to take, can anyone recommend a tutorial guide? I would love to hear from any devs who have invested a lot time in this area. Many thanks!
  4. In Phaser 2, the following was available for use - getTileWorldXY - https://phaser.io/docs/2.4.4/Phaser.Tilemap.html#getTileWorldXY What would be the Phaser 3 equivalent sense getTileWorldXY is not available in this version? Thanks
  5. blackhawx

    How to collide a Sprite with a Graphic

    hmm.. thats not working for me. my crate sprite still does not collide with my yellow graphic
  6. I'm using the following two examples as references in trying to get a sprite to collide with a basic shape, using arcade mode. To create my graphic https://labs.phaser.io/edit.html?src=src\game objects\graphics\fill rounded rectangle.js To create collision http://labs.phaser.io/edit.html?src=src/physics\arcade\static body.js And here is what I came up with: class FirstScene extends Phaser.Scene { constructor() { super({ key: 'FirstScene', active: true, physics: { default: 'arcade', arcade: { debug: false, gravity: { y: 100 //the game gravity } } } }); console.log('my constructor'); } init() { console.log('the init method'); } preload() { console.log('the preload method'); this.load.image("crate", "game06/media/crate.png"); } create() { console.log('the create method'); //add my sprite and associate gravity mcrate = this.physics.add.sprite(180,100,'crate'); //set world boundary for my crate mcrate.body.setVelocity(100, 200).setBounce(1, 1).setCollideWorldBounds(true); //now add a simple graphic to stage mshape = this.add.graphics(); mshape.fillStyle(0xffff00, 1); mshape.fillRoundedRect(32, 22, 700, 10, 5); } update() { //console.log('the update method'); //attempting to add collision between my sprite and my graphic, but no luck... this.physics.world.collide(mcrate, [mshape]); } } const config = { type: Phaser.AUTO, width: 800, height: 600, title: 'Training with Scenes', backgroundColor: "#87CEEB", scene: [FirstScene] }; var game = new Phaser.Game(config); let mshape, mcrate; i'm on Phaser 3.12. What am I missing to get my 2 objects to collide? Thanks
  7. blackhawx

    Best way to get objects to slightly slide before stopping

    I'm making note of your advice when I run into similar situations in the future. Many thanks!
  8. I ran across the following article online in getting objects to slightly slide as we press LEFT or RIGHT on keyboard. - https://gamemechanicexplorer.com/#platformer-3 I'm not sure if that source is outdated or not, but is there a Phaser 3.12+ version of what that article is describing? For my game, I have the following in my update function which appears to be working in getting my player to go left and right. But player stops instantly due to the `setVelocityX(0)` that is set in place. How could I enhance this script? function create() { ... //the initial cursor object for keyboard controls cursors = this.input.keyboard.createCursorKeys(); ... } function update(time,delta) { if (cursors.left.isDown) // if the left arrow key is down { player.body.setVelocityX(-200); // move left player.anims.play('walk', true); // play walk animation player.flipX= true; // flip the sprite to the left } else if (cursors.right.isDown) // if the right arrow key is down { player.body.setVelocityX(200); // move right player.anims.play('walk', true); // play walk animatio player.flipX = false; // use the original sprite looking to the right } else { player.body.setVelocityX(0); player.anims.play('idle', false); } //player jumping if ((cursors.space.isDown || cursors.up.isDown) && player.body.onFloor()) { player.body.setVelocityY(-500); // jump up } }
  9. blackhawx

    Help debugging through Physics with Phaser 3

    I'm using the following 2 projects as a reference https://www.emanueleferonato.com/2018/02/21/your-first-phaser-3-matter-js-physics-example/ http://labs.phaser.io/edit.html?src=src\physics\arcade\simple body.js
  10. Hello, I'm working with Phaser 3.12.0 and I'm attempting to experiment with debugging in general. I am failing to get any debug information with the following game code.... const config = { type: Phaser.AUTO, width: 640, height: 480, backgroundColor: "#000044", // physics settings physics: { // we are using matter.js engine that is built into Phaser default: "matter", arcade: { debug: true } }, scene: { init: init, preload: preload, create: create, render:render } }; let game = new Phaser.Game(config); function init() { console.log('the initializer'); } function preload() { console.log('the preload'); this.load.image("crate", "game04/media/crate.png"); } function create() { console.log('the the update'); this.matter.world.setBounds(0, -200, game.config.width, game.config.height + 200); // waiting for user input this.input.on("pointerdown", function (pointer) { console.log('we are clicking for an event to fire'); // getting Matter bodies under the pointer var bodiesUnderPointer = Phaser.Physics.Matter.Matter.Query.point(this.matter.world.localWorld.bodies, pointer); // if there isn't any body under the pointer... if (bodiesUnderPointer.length == 0) { // create a crate this.matter.add.sprite(pointer.x, pointer.y, "crate"); } // this is where I wanted to remove the crate. Unfortunately I did not find a quick way to delete the Sprite // bound to a Matter body, so I am setting it to invisible, then remove the body. else { bodiesUnderPointer[0].gameObject.visible = false; this.matter.world.remove(bodiesUnderPointer[0]) } }, this); } function render() { // Camera game.debug.cameraInfo(game.camera, 32, 32); } I guess I just need a basic understanding of how to debug through Phaser 3. I borrowed some examples from the labs and placed them in here, in hope to see something. But like I said, absolutely no debug information is being displayed. What would be a potential reason? Thanks
  11. blackhawx

    Generic platformer + ES6 / Webpack 4 boilerplate

    Nice game. What part of your code is forcing the canvas width to be set to 1600px?
  12. blackhawx

    Understanding the on method in Phaser 3

    Thanks prob! This helps me move forward.
  13. If I have the following in my game code... this.input.on('gameobjectup', this.clickHandler, this); Is `gameobjectup` a pre-defined term that Phaser already understands, or is that a just a required label that I can rename as anything I want? If the former, is there documentation online that tells us what other values we can use in it's place? Thanks!
  14. blackhawx

    Referencing objects between scenes

    Understood, thanks for clearing things up!
  15. blackhawx

    Referencing objects between scenes

    Thank you so much rich for the feedback. I apologize if my original concern is slightly unclear. What I would like to know is why we can't we do something like the following, to cut down on typing the keyword 'this' every time... /* my original code */ this.enemy1.scaleX = 1; //another way of scaling! this.enemy1.scaleY = 1; //another way of scaling! /* can we do something like this in Phaser 3 so that properties are stored under a single this keyword? I've tested this short example but it breaks on me. Can I tweak it to get it working? */ this.enemy1 = { scaleX : 1, scaleY : 1 } Is this not acceptable in Phaser 3? Many thanks!