• Content Count

  • Joined

  • Last visited

About Doug

  • Rank
    Advanced Member

Recent Profile Visitors

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

  1. Just following this up. I discovered that it was a plugin "smoothScroll" that I was using. Once I disabled that it worked fine
  2. Hi All. I've just created a Phaser3 game and added it to an page. When I use the up or down keys the page scrolls rather than the character moving. I understand that this is something to do with event.preventDefault() for keydown, but I can't get it working. It works fine in a basic html page, but not in the page. Here is the html page that DOES work: <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> <script src="phaser.min.js" type="text/JavaScript"></script> <script src="game.js?1" type="text/JavaScript"></script> <meta http-equiv="cache-control" content="max-age=0" /> <meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="expires" content="0" /> <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> <meta http-equiv="pragma" content="no-cache" /> </head> <body style="text-align:center; padding-top:250px; padding-bottom: 3000px;"> <div id="otterGame"></div> </body> </html> Working live example: Here is the page that is having the problem: <%@ Page Title="" Language="VB" MasterPageFile="~/Public/Main.master" AutoEventWireup="false" CodeFile="MediaAndResources_Game.aspx.vb" Inherits="Public_MediaAndResources_Game" %> <%@ Register src="../controls/V2/BreadCrumb.ascx" tagname="BreadCrumb" tagprefix="uc1" %> <%@ Register src="../controls/V2/QuickLinks_7.ascx" tagname="QuickLinks_7" tagprefix="uc2" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <link rel="stylesheet" type="text/css" href="../Game/style.css"> <script src="../assets/js/phaser.min.js" type="text/JavaScript"></script> <script src="../Game/game.js?2" type="text/JavaScript"></script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder_imageBar" Runat="Server"> <uc1:BreadCrumb ID="BreadCrumb1" runat="server" PageTitle="Game" Level1_Title="Home" Level1_URL="Default.aspx" Level2_Title='' Level2_URL="" Level3_Title="Game" /> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder_Body" Runat="Server"> <div class="row margin-bottom-20"> <div class="col-md-3 col-sm-3"> <uc2:QuickLinks_7 ID="QuickLinks_21" runat="server" /> </div> <div class="col-md-9 col-sm-9"> <h1>Otter Madness</h1> <div id="otterGame"></div> </div> </div> </asp:Content> You can see the live page here: I'm adding the keys like this: this.upKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.UP); this.downKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DOWN); ...and then checking their state in the update function like this: if (this.upKey.isDown) { //Do some stuff }else if(this.downKey.isDown){ //Do some more stuff } Any idea what's I can do to fix this please? Thanks very much!
  3. 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
  4. 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!
  5. 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. 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!
  7. Just to follow up on this, I can confirm that @rgk was right. I changed the code to the following and it all works.; Thanks again
  8. 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. 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. @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!
  11. You're most welcome. I assume you've found the documentation here too: Between the labs and the docs you should have everything you need. Enjoy! It's a great framework.
  12. 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.
  13. Doug

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

  14. 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)?
  15. Hi Josh I think you're looking for this:\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