brentstrandy

Members
  • Content Count

    38
  • Joined

  • Last visited

About brentstrandy

  • Rank
    Advanced Member

Contact Methods

  • Twitter
    brentstrandy

Recent Profile Visitors

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

  1. brentstrandy

    SVGs on IE11 throw error

    Has anyone successfully loaded an SVG file on IE11? Even the Phaser 3 SVG example crashes on IE11.
  2. brentstrandy

    How to pass click event?

    Can't you use emit? To use NoxBrutalis' example: this.button = this.add.sprite(xy.x, xy.y - 96, 'start').setInteractive(); this.button.on('pointerover', function(){this.button.setTint(0xf0ff00);}, this) this.button.on('pointerout', function(){this.button.setTint(0xffffff);}, this) this.button.on('pointerdown', function(){ //do things on click }); // This line calls the function associated with the button's 'pointerdown' event this.button.emit('pointerdown');
  3. brentstrandy

    Mobile Audio *Crash Bug*

    You're amazing. Thank you! Hopefully the console log with provide more details. I'm loading MP3's - I thought this file type was compatible on mobile?
  4. brentstrandy

    Mobile Audio *Crash Bug*

    I have the following code to load all my Audio files [ 'file1', 'file2', 'file3', 'file4', ].forEach(element => { this.load.audio(element, 'sounds/' + element + '.mp3'); }); This works wonderfully on a desktop, but on mobile I get the following error: TypeError: null is not an object (evaluating 'e.message') The error occurs in AudioFile.js (Line 100). Here is an excerpt, I've added a comment where the error is thrown: onProcess: function () { this.state = CONST.FILE_PROCESSING; var _this = this; this.config.context.decodeAudioData(this.xhrLoader.response, function (audioBuffer) { _this.data = audioBuffer; _this.onProcessComplete(); }, function (e) { // ERROR occurs on this line (e is null) console.error('Error decoding audio: ' + this.key + ' - ', e.message); _this.onProcessError(); } ); this.config.context = null; }
  5. brentstrandy

    Pass custom variable into Phaser.Game()

    Is there a chance someone knows what to do here?
  6. brentstrandy

    Load SVG containing multiple images

    ANSWER: Load the SVG as a spritesheet this.load.spritesheet( 'avatar', 'images/avatar_animations.svg', { frameWidth: 89, frameHeight: 184, endFrame: 10 } ); And later in code you can do this: let avatarImage = this.add.sprite(200, 200, 'avatar'); // Assuming you've added a jump animation.... avatarImage.anims.play('jump');
  7. brentstrandy

    Load SVG containing multiple images

    I'm able to load an SVG file containing a single image. Is it possible to load an SVG that contains multiple images? Is it possible to animate multiple SVG files?
  8. brentstrandy

    Audio Play on Event?

    You have to bind the context to your callback function this.player.on('animationrepeat', function () { if(this.anims.currentAnim.key === 'move') { this.sound.play('playerStep'); } }.bind(this));
  9. brentstrandy

    Audio Play on Event?

    Ideally I would connect your SFX to a walking animation. So if you ever get a walking animation you can add the following code: this.player.on('animationrepeat', function () { if(this.player.anims.currentAnim.key === 'walking') { this.sound.play('playerStep'); } }); The above code will play a SFX every time the animation loops - which means it will *probably* play every time the player takes a step. Without an animation you can do the following: function create () { this.sound.add('playerStep´╗┐'); // Create an event that fires every half-second and plays a footstep // sound if the player is currently walking this.footsteps = this.time.addEvent({ duration: 500, repeat: -1, callbackScope: this, callback: function () { if(this.player.isWalking) { this.sound.play('playerStep'); } } }); // Create the cursors only once - not every game loop this.cursors = this.input.keyboard.createCursorKeys(); } function update (time, delta) { if (this.cursors.right.isDown && this.player.body.onFloor()) { this.player.isWalking = true } else { this.player.isWalking = false } }´╗┐
  10. brentstrandy

    Use spriteSheet and delete

    Maybe have 2 active scenes in your game?? One scene that displays the map and one scene that displays the game.
  11. brentstrandy

    Bring to top container

    @andrei.nicolae Put this line of code inside the pop-up scene before showing the container and it will move the pop-up to the top of the display order this.scene.bringToTop();
  12. brentstrandy

    Keyboard preventDefault

    I found the solution digging through the Phaser 3 code event.preventDefault() will not be called unless the specific Key has been added to Phaser's Keyboard list of Keys. See Phaser 3 code below: var key = _this.keys[event.keyCode]; if (key && key.preventDefault) { event.preventDefault(); } Reference: https://github.com/photonstorm/phaser/blob/16f61b402b8aa50b09a869c85a840eed363e1052/src/input/keyboard/KeyboardPlugin.js#L234 When I add "this.input.keyboard.createCursorKeys();" to my code, the Keyboard object creates Keys for the directional (cursor) keys and will call preventDefault() on keydown events. this.input.keyboard.createCursorKeys(); this.input.keyboard.on('keydown', e => { this.handleInput(e); });
  13. brentstrandy

    Cant get player to display

    You set your player's position to 0,0 - this means the bottom right corner of your player is set to 0,0. Try adding .setOrigin(0) like this: player = this.physics.add.sprite(32, config.height - 150, "ship").setOrigin(0); This will make the top left corner of your player set to 0, 0
  14. brentstrandy

    Keyboard preventDefault

    Even though my individual keys all have "preventDefault = true" and my keyboard event says "defaultPrevented = true" I'm still finding the DOM is processing my keyboard events. I have the following event callback on keypress: this.input.keyboard.on('keydown', e => { this.handleInput(e); e.preventDefault(); }); Am I using the "preventDefault" property correctly?
  15. brentstrandy

    Pass custom variable into Phaser.Game()

    I'm trying to seed my game with custom data. For example, in Phaser 2 I was able to instantiate a new Game object with any number of parameters. It seems Phaser 3 is only looking for a config object with specific properties and nothing more. Is there a way to do this? new Phaser.Game({ type: Phaser.AUTO, width: 916, height: 400, scene: [BootScene, PreloaderScene, MenuScene, GameScene], antialias: true, myCustomObject: { } }); Note the "myCustomObject" passed into the game. I would prefer to keep my Phaser implementation to one line and not have to resort to the following: var myGame = Phaser.Game(config); myGame.scene.start('myScene', myCustomObject);