Doug

Members
  • Content Count

    56
  • Joined

  • Last visited

Everything posted by Doug

  1. Hi Quick one (hopefully). Is using the resolution setting the best way to deal with HDPI screens on mobile? i.e. set the game size to the innerHeight and innerWidth of the screen and then set the "resolution" setting to the devicePixelRatio. It seems to work, but I am getting a bit of a performance lag. I assume just because the higher resolution means that device is working harder rather than because it's not the proper solution? Thanks :) D
  2. Doug

    Resetting a scene

    Hi All I couldn't find a method to restart / reset a scene. Anyone know if there is one please? Or if there is a better way to do this. Thanks!
  3. Doug

    Changing scenes

    I am sure this is a completely dim question, but I can't find what I'm looking for. I'm using Angular4 with phaser: this.phaserGameConfig = { type: Phaser.WEBGL, width: width, height: height, parent: 'game-play', scene: null }; this.phaserGame = new Phaser.Game(this.phaserGameConfig); this.phaserGame.scene.add('GAME_0_Loading', new GAME_0_Loading(this.phaserGameConfig, this), false); this.phaserGame.scene.add('GAME_1_Welcome', new GAME_1_Welcome(this.phaserGameConfig, this), false); //etc I have around 10 scenes and I need to change between them so that each time the scene loads it starts afresh each time. i.e. any old scenes are completely destroyed and when I load the scene all the elements load from scratch as if the scene has never loaded before. I was thinking that the way to do this would be: this.phaserGame.scene.start(sceneName); However, when I do this I am seeing what appears to be legacy stuff from previous instances of the scenes. I am finding that I am having to do: this.phaserGame.scene.stop(theCurrentSceneKey); To prevent very odd overlays of buttons etc on scene changes. Further, tweens that I have used to bring elements into the screen are taking more time before they run each time one particular scene loads. As if the time delay for the tween is being added to on each load of the scene. Any guidance would be appreciated. If you need any more code samples then let me know Thanks!
  4. Doug

    Phaser3 and Ionic Framework

    Hi All I'm developing a mobile app with ionic framework and Phaser 3 and am having some problems. When I run ionic serve the app opens in the web browser and works fine. However, when I run ionic build I have problems. I know that Phaser loading because I am seeing the following in the console (this is running the version that has problems when I ionic build it): However, I get a black screen rather than any game content. I am including phaser in the index.html file: <script type="text/javascript" src="assets/libs/phaser/phaser.min.js"></script> Then referencing it within my component: declare var Phaser: any; As I say, it works fine until I do a full ionic build. Anyone seen this before? Any ideas why it would happen please? Thanks!
  5. Doug

    Phaser3 and Ionic Framework

    OK, so I think I may have worked out what's going on here, but I'd welcome feedback as to whether I'm correct and how to resolve it please. When I run `ionic serve` my games run perfectly. When I do `ionic build` and open the files directly in a browser they fail. This, I have now realised is a dim mistake because a web server is required to serve phaser games. So if I run a basic python web server in the www build directory with `python -m SimpleHTTPServer` I can then browse to the game in the web browser at http://localhost:8000/ and boom, the games are working. So, the question is.....Is the reason that the games in my ionic app fail that they are not being run with a webserver when they are running in a compiled app? If so, then how do I get around that? Thanks very much!
  6. Doug

    Destroying a matter.js rectangle body

    Just to follow up on this, I can confirm that @rgk was right. I changed the code to the following and it all works. this.matter.world.remove(this.wireRect); Thanks again
  7. Hi all I'm creating a matter.js rectangle body with the following code: let wireRect = this.matter.add.rectangle(w.x, w.y, this.wireLength, 10, { restitution: 0.9, isSensor: true, angle: angle }); I then later need to remove it from the game. wireRect.destroy(); returns an error "wireRect.destroy is not a function". I have another game in which I am using this.matter.add.image(XXX) and the .destroy() method works fine on those. So I tried: this.matter.world.remove(this.matter.world, wireRect); That doesn't seem to work either. I can see matter.body documentation https://photonstorm.github.io/phaser3-docs/MatterJS.Body.html, but can't see how I would find the correct destroy method for it. Any ideas welcome please! Thanks
  8. Doug

    UI Elements on Phaser 3

    I would probably avoid trying to create the login form etc within Phaser. As @snowbillr has hinted at, this would not be all that easy and you're going to need a workaround. Maybe a better approach would be to create an HTML form within a div with a background so that it looks pretty and as if it's a part of the game, but is actually just pure html, css, JS etc and then create or show the Phaser game instance after the login has been processed.
  9. Doug

    Destroying sounds - best practice

    Thanks very much @samme - I am actually using the latest version of Phaser, but I just had another look at my code. It's pretty complicated in there now and it looks like there was one instance where I wasn't destroying the game properly, but just closing the modal. I've amended it now and so far it appears to have done the trick. So I'll do some more testing. Thank you and sorry for wasting your time if it was this.
  10. Hi all I am using Angular 4 and creating an interface which has a number of games. They load in a modal (i.e. no page refresh/change) and I then destroy them with this.phaserGame.destroy(true); I have background audio that I am playing with the following: preload () : void { this.load.audio('bg', [ this.p('audio/bg.mp3'), this.p('audio/bg.ogg') ]); } this.p() just gets the relative path. create () : void { this.sound_bg = this.sound.add('bg', { loop: true }); } When I destroy and reload the game, the background audio object seems to still be in the DOM and plays over itself on second game launch. I've had a look through the documentation and tried removeByKey() remove() and destroy() in the BaseSoundManager() namespace just before destroying the game. None of these seem to solve the problem though. What is best practice for completely destroying sounds please? Thank you!
  11. Doug

    Destroying sounds - best practice

    @rich Sorry to bother you, but I'm still struggling with this one and it's causing me a lot of headaches. What is the best way to completely remove sound from the DOM please? Thanks!
  12. Doug

    onkeyup event (onUp)

    You're most welcome. I assume you've found the documentation here too: https://photonstorm.github.io/phaser3-docs/list_namespace.html Between the labs and the docs you should have everything you need. Enjoy! It's a great framework.
  13. Doug

    Destroying a matter.js rectangle body

    You are a legend, thanks. I can replicate this working in the example page you sent too Will have a go at implementing in my code as soon as I have a chance. Thanks very much! Greatly appreciated.
  14. Doug

    Hi Rich.  @rgk mentioned that you might be able to please add a "patron" badge to my forum profile?  Thanks very much!

  15. Doug

    Destroying a matter.js rectangle body

    Thanks very much. However, the objects still accept collisions etc and also still show up in debug mode. Have you had this working successfully? Just out of interest, how did you get the "Phazer patron" badge to display (I am a patron, but it's not showing for me)?
  16. Doug

    onkeyup event (onUp)

    Hi Josh I think you're looking for this: http://labs.phaser.io/edit.html?src=src\input\keyboard\keydown.js You just replace `keydown` with `keyup`. e.g. this.input.keyboard.on('keyup_A', function (event) { console.log('Hello from the A Key!'); }); I hope this helps and let me know how you get on D
  17. Doug

    Rotation of arcade physics body

    No problem at all. I really appreciate that you tried.
  18. Hi Forgive me if I've missed this, but I can't find it in any of the documentation. Is there a way to specify the the rotation of an arcade physics body? I can rotate the game object image, but that has no effect on the physics body. I would have expected a .setAngle or .setRotation method to be available on Phaser.Physics.Arcade.Body. Seems such a simple one to miss, but I keep needing this and having to use matter, which is just a little more fiddly. Thank you!
  19. Doug

    Rotation of arcade physics body

    Great thank you. Will do.
  20. Doug

    Rotation of arcade physics body

    Thanks, that's really kind of you. Just did the same to check it and it still fails here. It rotates the game object, but not the physics body. let t = this.physics.add.sprite(200, 200, 'sprites', 'windSock_0000'); t.angle = 30;
  21. Doug

    Rotation of arcade physics body

    Thanks. I tried this, but it doesn't work. I tried the following: let t = this.physics.add.sprite(100, 100, 'sprites', 'windSock_0000'); t.body.rotation = 1; ...and let t = this.physics.add.sprite(100, 100, 'sprites', 'windSock_0000'); t.body.angle = 30; Interestingly it doesn't give an error. It just does nothing. I also tried with image and staticImage gameobject types. Do you think this is maybe a bug?
  22. Doug

    Video game object

    Hi All Forgive me if I've missed this, but I can't seem to find any examples or reference to being able to create video game objects / textures. Is this possible please? I am thinking of mp4 or ogg video playing on a game object within the game. Mainly for use in things like interactive product tours etc. I note that the Phaser.Device namespace has a "video" member. I also note that Rich mentioned the video.OnComplete event handler in one of his posts too. So I am wondering if there is support for actual playback too? Thanks very much!
  23. Doug

    Animation pivot points

    Update: Andreas at Code And Web pointed me to this: https://github.com/photonstorm/phaser/issues/3288#issuecomment-369294565
  24. Doug

    Animation pivot points

    Hi all I've got an animation of a running ninja (original hey). Sprite sheets attached. I am doing the following in my code: Preload function: this.load.atlas('sprites', this.p('Sprites.png'), this.p('Sprites.json')); Create function: this.ninja = this.physics.add.sprite(this.gameWidth/2, this.gameHeight/2, 'sprites', 'stand').setCollideWorldBounds(true); let runConfig = { key: 'run', frames: this.anims.generateFrameNames('sprites', { prefix: 'run', start: 1, end: 7, zeroPad: 0 }), repeat: -1, frameRate: 5 } this.anims.create(runConfig); this.ninja.play('run'); I am using texturepacker (https://www.codeandweb.com/texturepacker) to create the sprite sheet as a Phaser3 spritesheet. I have set the pivot points for each frame to be on the ninja's chin so that the head is always still when he is running. When I run the game the character jolts left and right as if it is ignoring the pivot points that I've set in texture packer. Is this a bug or am I missing something obvious please? Thanks so much! Sprites.json
  25. Yeah, I was very keen NOT to eject the project because it makes things a lot more complicated. I did manage to get it working via that route by making some changes to the webpack config file that gets generated when you eject the project. However, it wasn't much fun working with the project once ejected. I ended up NOT ejecting the project but just including the phaser JavaScript file in the "scripts" section of .angular-cli.json. Then in the component where I use phaser I added: declare var Phaser: any; I think that was everything I did. It works a treat and means I can easily update the phaser JavaScript file by just replacing it rather than using npm as Rich iterates the updates and fixes bugs etc. I hope that helps and let me know if I missed anything.