• Content Count

  • Joined

  • Last visited

  • Days Won


brentstrandy last won the day on March 29 2019

brentstrandy had the most liked content!

About brentstrandy

  • Rank
    Advanced Member

Contact Methods

  • Twitter

Recent Profile Visitors

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

  1. Has anyone successfully loaded an SVG file on IE11? Even the Phaser 3 SVG example crashes on IE11.
  2. 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. 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. I have the following code to load all my Audio files [ 'file1', 'file2', 'file3', 'file4', ].forEach(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) { = 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. Is there a chance someone knows what to do here?
  6. 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....'jump');
  7. 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. You have to bind the context to your callback function this.player.on('animationrepeat', function () { if(this.anims.currentAnim.key === 'move') {'playerStep'); } }.bind(this));
  9. 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') {'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) {'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. Maybe have 2 active scenes in your game?? One scene that displays the map and one scene that displays the game.
  11. @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. 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: 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. 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. 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. 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);