• Content Count

  • Joined

  • Last visited

  • Days Won


Reputation Activity

  1. Like
    Noid got a reaction from Rhyllgar in Sound in Opera   
    If you offer both mp3 and ogg, make sure you put ogg files first in the array. When asked about mp3 support Opera answers "probably"(not joking) so phaser will try to play the mp3 files if they're first in the array.
    You probably want to offer both if you want audio to work on IE and/or Safari.
  2. Like
    Noid got a reaction from jamespierce in I know what the hearts mean   
    (Either I'm the first to notice this or everyone thinks it's so obvious they didn't bother to write a forum post about it  )
    When I run my game, I see two red hearts and a gray one next to "Phaser vX.X.X ...". I thought it was just decoration but I noticed in screenshots from other people that sometimes there are three red hearts. So I inspected the piece of code responsible for the output of that line which, with 'pretty print' enabled, reads: 
    var a = b.VERSION, c = "Canvas", d = "HTML Audio", e = 1;if (this.renderType === b.WEBGL ? (c = "WebGL", e++) : this.renderType == b.HEADLESS && (c = "Headless"), this.device.webAudio && (d = "WebAudio", e++), {                for (var f = ["%c %c %c Phaser v" + a + " - " + c + " - " + d + "  %c %c  %c %c ♥%c♥%c♥ ", "background: #0cf300", "background: #00bc17", "color: #ffffff; background: #00711f;", "background: #00bc17", "background: #0cf300", "background: #00bc17"], g = 0; 3 > g; g++)                    f.push(e > g ? "color: #ff2424; background: #fff" : "color: #959595; background: #fff");                console.log.apply(console, f)            } Notice there is an 'e' variable that starts at 1 and is incremented  when c = WebGL and d = "WebAudio". There is also a loop using a 'g' variable and at the end an f.push line that compares e to g and according to which is greater sets color to #ff2424(red) or #959595(gray).
    So the meaning of the hearts are: 
    ♥: Basic functionality
    ♥♥: Either WebGl or WebAudio enabled
    ♥♥♥: WebGl and WebAudio enabled
    That's really cool!
  3. Like
    Noid reacted to tembac in Rotate body position with sprite angle   
    Found a solution

    I was calculating the anchor wrong. Now I found the exact anchor point on Photoshop and divided it with the file size:
    this.anchor.set(460 / 814, 400 / 814);  
  4. Like
    Noid got a reaction from tips4design in WebGL slower than canvas [FIX]   
    Maybe debug.text should output some warning to the console since it severely affects performance and people new to phaser have no way of knowing
  5. Like
    Noid got a reaction from drhayes in 2.4.7 -> 2.4.8 body anchoring. Any migration tips?   
    The problem seems to be that the empty space is being trimmed but the engine is not loading the metadata properly. 
    This is part of my atlas.json file
    {"filename":"Pichon_Vuela00.png", "frame": {"x":865, "y":391, "w":58, "h":58}, "spriteSourceSize": {"x":8,"y":1,"w":77,"h":66}, "sourceSize": {"w":77,"h":66} }, {"filename":"Pichon_Vuela01.png", "frame": {"x":550, "y":411, "w":65, "h":57}, "spriteSourceSize": {"x":5,"y":1,"w":77,"h":66}, "sourceSize": {"w":77,"h":66} }, {"filename":"Pichon_Vuela02.png", "frame": {"x":616, "y":411, "w":64, "h":56}, "spriteSourceSize": {"x":6,"y":0,"w":77,"h":66}, "sourceSize": {"w":77,"h":66} }, If I console.log sprite.width while the animation is running I get the following values: 58, 65, 64. Those are the widths on the atlas image, were the sprites are tightly packed ignoring transparent pixels. However, when extracted from the atlas they should all be 77x66 as defined in sourceSize and spriteSourceSize. 
    Maybe the atlas format changed and my .json file is no longer up to spec, but I can't find the specs anywhere on the repo.  

    UPDATE: I couldn't find the specs but I could find some examples on the examples repo and it seems my json is no longer up to spec. It now needs a "trimmed" : true property in each frame that has been trimmed. Sorry, must've missed the update where that was added. 
    Thanks for all the help, Tom! I think everything's working fine now. 
  6. Like
    Noid got a reaction from BdR in Questions about tilemap interactions   
    I published a game just like the one your're making ( last year so I can tell you how I ended up solving the same problems. 
    All I say implies I'm using arcade physics though in retrospect maybe I should've used P2. You should test both now to see which one you find more suitable before it's too late. 
    Regarding bounce, I have a variable that holds the jump speed and apply that whenever body.onFloor() is true. Using onFloor you avoid having it bounce when it touches the sides or bottom of a tile. 
    Regarding pass through blocks, I didn't use any of those but collide() allows you to define a callback so you can do additional checks before returning true or false. you can check that the player is falling and colliding with the top of the pass-through tile or return false otherwise.
    When you collide a tilemap with a sprite you can also decide what to do besides separation in a collision callback. The callback will provide a reference to the sprite and the tile that are colliding, so you can check the tile index and decide what to to in each case. Is is a spring? Let's make the player jump higher and faster. Is it a spike? Let's kill the player. Is it the exit door? Let's exit the level. 
    You can have collision callbacks assigned to a tileindex with setTileIndexCallback() but if every tile in the map is gonna have a callback then I think it's better to just add a callback to collide() and check the tile index yourself
  7. Like
    Noid reacted to Tom Atom in 2.4.7 -> 2.4.8 body anchoring. Any migration tips?   
    Hi, this answer is going to be long...
     I am answering your question as 2.4.8 fix/change was made based on my GitHub issue (, so I feel little responsible for it...
     I will use test graphics 60x60 pixels and it will be always tested with anchors from 0,0 to 1,1 (in 5 steps) on these 4 scenarios:
    setSize(30, 30 0, 0) and scale.x = 1 setSize(30, 30, 15, 15) and scale.x = 1 setSize(30, 30 0, 0) and scale.x = -1 setSize(30, 30, 15, 15) and scale.x = -1  In Phaser 2.4.7 two lines in src/physics/arcade/Body.js looked like this:
    this.position.x = ( - (this.sprite.anchor.x * this.width)) + this.offset.x; this.position.y = ( - (this.sprite.anchor.y * this.height)) + this.offset.y;  Which produced results like this (red dot is anchor, green rect is body debug):

     As you can see on first row, despite offset was requested 0,0, it is actually changing from 0,0 to -30, -30, depending on the anchor. Your problem is with setting scale x to -1. You can see, you were lucky in Phaser 2.4.7, because happily it produced the same result in first row (third image) and in third row (third image). But having your anchor different from 0.5, 0.5 would produce less predictable results.
     In Phaser 2.4.8 source was changed to:
    this.position.x = ( - (this.sprite.anchor.x * this.sprite.width)) + this.offset.x; this.position.y = ( - (this.sprite.anchor.y * this.sprite.height)) + this.offset.y; It produces results:

    In first two rows, you can see, that setting setSize produces predictable result regardless of anchor. Body is now always set from top left corner of the sprite and its position is not influenced with sprite's anchor changes. Unfortunately, that change was obviously not enough to take into acount axis flips...
     So, suggested change may be like this, which takes into account also flips (negative scales):
    this.position.x = ( - (this.sprite.anchor.x * this.sprite.width)) + this.sprite.scale.x * this.offset.x; this.position.x -= this.sprite.scale.x < 0 ? this.width : 0; this.position.y = ( - (this.sprite.anchor.y * this.sprite.height)) + this.sprite.scale.y * this.offset.y; this.position.y -= this.sprite.scale.y < 0 ? this.height : 0; It will produce these results:

    It keeps positioning made in 2.4.8 and add correction when scale is negative. Now, your body is always correctly offseted from top left (or top right with negative x scale).
    If Rich is reading this and agrees with suggested changes, I will create GitHub issue for it...
  8. Like
    Noid got a reaction from in mono in IDE with autocomplete for Phaser   
    Since you say you're lerning JS, I want to let you know that nothing will have perfect autocomplete for javascript due to the way the language works. Since it's a weakly typed language sometimes there's no way to know what's inside an object until runtime(and that may even change serveral times during execution). 
    Some editors include ternjs which tries to get as much autocomplete info as possible but I'm using sublime 3 with no autocomplete plugin and open on a browser tab and I've managed just fine. 
  9. Like
    Noid got a reaction from sebab97 in Animated tiles with Tiled   
    Cool! I've played some of the early versions of AO.
    Unfortunately I think Phaser doesn't support animated tiles. You can probably use an instance of Phaser.BitmapData as a tileset image and then use BitmapData.copyRect() to paste the required frames at regular intervals. I don't know how fast it'd be but it'd probably be faster than using Phaser.Tilemap.replace(). 
    Since this might be useful for my game too, I'll try to make it work and post the code as soon as possible. 
  10. Like
    Noid got a reaction from vohogames in Phaser with intel xdk sound problem   
    The emulator in IntelXDK doesn't play mp3s. If it doesn't properly inform what is capable of playing, phaser will just pick the first option. This happens with Opera to. Just put the ogg files first in the array. Going from 44100 to 8000 will noticeable degrade sound quality.
  11. Like
    Noid reacted to rich in Your feedback on the future of Phaser wanted   
    Thanks for your comments everyone. I won't address them all but just want to add a few things:
    1) I released Issue 1 of Phaser World today. I spent quite a few hours last night creating scripts to automate the process, so the content is pulled from the Phaser site and I don't have to write lots. By doing this I believe I can publish once a week, but I may opt for every 2 weeks. Will decide next Friday
    2) It's no surprise that people want (and value) knowledge above plugins. We're working on Interphase 2 at the moment, so we'll see how that goes. I'm undecided what to do with the current un-released plugins. I'm thinking I may just get them finished and on sale and be done with it. Over time they will earn back what they cost, and it doesn't matter if that takes a long time. It's a waste for them to sit doing nothing.
    3) The comments about noobs is interesting. I feel we could definitely do with a real solid 'Beginners Guide'. I would love to write a book like this and release it for free (if the Patreon amount gets high enough it's one of the things on the list actually), although I guess doing it anyway is a good way to encourage more devs into the fold. Then again, I'm not sure that getting new devs is an issue we actually face right now.
    4) Not knowing what games to show people is an interesting one. We do actually collate a "Staff Picks" list, which has some seriously incredible games on it! I've added a link to this on the bottom of the home page, but if anyone asks in future it's a good one to give out.
  12. Like
    Noid got a reaction from Skeptron in reseting to 0,0   
    I'm experiencing some weird bug when my game loses focus as you can see below: 

    About a second after the game loses focus, and become 0,0. Camera position is unaffected. It doesn't happen if I switch to another tab, I can use the developer tools to check the value of and see they remain unchainged. It only happens when the game loses focus and the tab is active and visible. 
    I've manage to reproduce this bug on chrome and firefox, and using phaser 2.4.4-dev, 2.4.3, 2.4.2 and 2.3.0. 
    I thought it might be something related to camera.follow() so I've tried not following any sprite and manually setting the camera position somewhere other than 0,0, and I observe the same behavior.
    It doesn't seem to happen in the examples at
    EDIT: I've managed to find why it happens. I have game.scale.setResizeCallback set to call a function that itself calls resizeWorld() on the tilemap layer. I can workaround the bug by calling resizeWorld() only if game.paused is false. 
  13. Like
    Noid reacted to rich in Kiwi.js vs Phaser   
    The important thing to look at with those posts is the date on them, to appreciate what happened and when. But this is a perfectly fair question, so here goes a little history lesson
    When I left my previous company and started Photon Storm full time, my first project was to help build Kiwi.js for a company in New Zealand called Instinct Entertainment. It was just myself and one other part-time developer (the massively talented Ross Kettle). We had nothing to work from, no template as such, so we were literally creating it on the fly - and what's more, the html5 landscape was constantly shifting beneath us as well (back then even iOS hadn't accelerated canvas fully yet).
    After a few months we made the jump from plain JavaScript to TypeScript. This actually helped the project significantly at the time, as we had structure and clarity that was a bit lacking before. But I also needed to start doing client games as well (to pay the bills basically, as fun as frameworks are, they don't make you much money ) so my time was now split between Kiwi and client games. And I used Kiwi for most of those early games, which helped it grow and develop. But still I was essentially coding on my own most the time, and after a while that gets really tiring. Ross was doing loads as well, but like me he had his own projects too, so we'd get strange boughts of him not being able to do anything for a few weeks, and then doing loads, and the same from my end, and it all kind of gets mixed and muddled up (it's not a great way to run a project in hindsight). Even so I coded for months: days, nights, nights into mornings, literally thousands of lines of code.
    Kiwi was still closed-source at this point and was a quite monstrously sized project. Too much so really. At the time I really wanted it to support DOM as well as Canvas, and spent a good while refactoring to support this. In hindsight it probably didn't need it, but back then DOM was still significantly faster than Canvas in most browsers (you could argue, for certain games, it still is) but of course adding this dependency didn't help with the scale of the project. So I'm literally burning the candle at both ends, trying to manage a hugely growing small business and trying to keep Kiwi moving forwards with effectively zero project management.
    Remember no-one else was allowed to see what we were doing, we couldn't release it onto github (due to funding applications going on at the time) and it was all just getting too much. There weren't enough hours in the day to manage it all and I basically burnt out.
    To try and rekindle my love for it I literally spent a weekend while the family was away hacking together a crude conversion of Flixel. I literally copied it wholesale, having to rebuild classes that existed in AS3 and porting the others. A couple of days later I was done - it was small, clean and just worked, because it only tried to do a few things so it did them pretty well. It was called Kiwi Lite (a name that I feel is a strong indication of my mindset at the time) and I wanted to release it on github. I was told I couldn't use the name as Kiwi had to remain closed at that time. So I asked Adam (creator of flixel) if I could call it Flixel5, but he said he'd rather I didn't as it would confuse things with the Flash build. So I spent an hour brainstorming some names with my good friend Ilija and we settled on Phaser. He drew a cool little space dude sprite and logo and the first build was pushed to github on April 12th 2013.
    I had always intended it to be a 'younger brother' to the much more sophisticated and feature-complete Kiwi.js, and for a good while that is how it remained. But an interesting thing happened: other people started using it. It started to take on a life of its own, and a small but constant trickle of devs started submitting pull requests and bug fixes. And then people actually started making games with it. And this does a curious thing when you've been working effectively in isolation for so long: it motivates you, like nothing else possibly can.
    And although I carried on working on both for a while, I slowly drifted away to Phaser because I was getting real tangible feedback and support, and it was infectious. The team at Instinct hired other devs to work on Kiwi and they've done an excellent job of cleaning it up, adding in WebGL support and making it a really attractive framework, and they released the first beta late last year (and didn't even tell me ). It's still TypeScript to the core, something I moved away from with Phaser - a move that's well documented on the forum if you want to read about my troubles with it!, but it's well worth looking at and using, especially if you like TypeScript or come from AS3.
    And while they were finishing Kiwi, Phaser evolved. When I swapped to plain JavaScript that was the same time I swapped to using Pixi.js under the hood, mostly because Mat is such a great guy but also because it was tiny and clean and it made sense to me. Version 1.0 was released just under six months ago, and for some reason it's hit a real chord with developers.
    Just so we're clear there is (or was) no 'breach of contract' here. There was a simple agreement in place, and I literally poured my heart and soul in Kiwi development for months, way more time than agreed (or ever invoiced for!) because I believed in what I was building. I'm not involved in development of it any more though, because it's no longer my "baby". A lot of work has been done on it, lots of internals changed (for the better) and the new devs own it now. It's their creation and they don't need me sticking my oar in.
      I've really held back from promoting Phaser, I think in part because I felt guilty and somewhat humbled that people even liked it and used it! And I wanted to give Kiwi time to release and establish itself. You can count the number of posts about it on my blog on one hand for example, and even though it has been ready for months the web site is still just a single pager. But that didn't stop it growing in popularity. I'm genuinely amazed at how well it's going. I'm not really doing anything other than trying to constantly improve it and help people use it, but I guess those are 2 quite fundamental things   Phaser 2.0 is finally the version I'm truly, genuinely 100% happy with. I've spent weeks fixing bugs, making it simpler under the hood, using Pixi.js more intelligently and improving it as much as I can. It's taken a long time and a lot of work to get to this point and as corny as it sounds, absolutely none of this would have  happened if it hadn't been for the community around it. The more people that use it, the more I want to make it better. And for those that submit pull requests and help fix bugs, you're the best  When 2.0 ships in March I'm no longer going to hold back from promoting it, so you'll see it appearing in a lot more places and things will step-up a gear around the site and tutorials.   tl:dr - I spent a long time working on Kiwi, but am no longer part of that team. It's a great framework and well worth using. Phaser was a weekend creation born from a pit of frustration/depression that went mental and grew into what you see today, utterly unplanned, but utterly wonderful because of it.
  14. Like
    Noid got a reaction from JUL in Quick poll - should we allow Unity games here?   
    I think we just don't want the forums flooded with Unity games and we're struggling to find a set of criteria that will exclude the Unity folks we don't want without excluding the Typescript, Haxe, C2 and GameMaker folks we do want.
    - If we exclude games not developed with the web in mind, we exclude all the mobile games made using phaser.
    - If we exclude games that didn't require HTML5 coding skills we exclude what's created with C2, any drag and drop editor built on top of phaser and if we are too strict anything written in any language other than javascript.
    The most honest answer would be that Unity is becoming a monoculture and already has tons of forums and that we're excluding it so it doesn't drown out other options. However, in that case, would a less popular engine with a similar worflow and a similar HTML5 export such as Godot or GDevelop be acceptable?
    Otherwise I think It'll just look like we're trying to rationalize a prejudice against Unity users.
    Edit: What about requiring a number of previous posts before being able to post on Game Showcase? I know it's possible with some forum software. It'll stop people who don't intend to use the forum for anything other than the chance of getting their game featured on or @photonstorm. It's easier than evaluating on a case-by-case basis.
  15. Like
    Noid got a reaction from BrunoHautenfaust in Problem with IIFE   
    You are polluting the global scope. You have game and hero as global vars and if you add enemy, map, etc. you will keep adding global variables.
    A different alternative, and I think the most popular one, is putting everything inside one global object so it works as a namespace and you create just one global var.
    var MyGame = MyGame || {}; //Create the namespace if it doesn't exist already.MyGame.MyClass = function (arg1, arg2) { //Every instance of MyClass will get a copy of whatever you declare here //...};MyGame.MyClass.prototype.method1 = function (arg1, arg2) { //This function is available to all instances of MyClass //but it's created only once in memory};MyGame.MyClass.prototype.method2 = function (arg1, arg2) { //Same as method1}; More info:
    Of course this is javascript and there are many other ways to do it. 
  16. Like
    Noid got a reaction from in mono in Problem with IIFE   
    In that case *I think* you should load main.js before Player.js or at least have phaser already initialized so that game holds a reference to a Phaser.Game object. You're probably passing game to hero when game is still undefined. 
    Why are you using IIFEs?
    EDIT: Ok I know how you can keep the IIFE and fix the error.
    var hero = (function(){    var hero = {        init: function(game){             hero = game.add.sprite( / 2, 0, 'idle'); << ReferenceError            this.scale.setTo(0.6, 0.6);            game.physics.arcade.enable(this);            this.body.collideWorldBounds = true;        }    };    return hero;}()); when you call hero.init()  you pass a reference to the game as an argument. hero.init( will work within a Phaser.State
  17. Like
    Noid got a reaction from drhayes in does anyone agree? the object model needs real work.   
    I'm an illustrator who also enjoys coding and Phaser must be the first engine I use where I think of a feature and hours later I have it working. It's the most frustration-free experience I've had so far. Everything has sane defaults to get you started easily and is easy to tweak once you learn how. 
    The reason there are so may requests for help on things that should be obvious is because there are many people here who've probably never coded before, or who are new to gamedev, or who are new to reading the docs and thinking for 5 minutes about a problem before posting on a forum. 
    It took me only a few minutes of reading two pages from the docs and some examples to understand how tilemaps work in phaser. If I were to build one myself I'm sure it would take me longer than that.
  18. Like
    Noid got a reaction from jdnichollsc in does anyone agree? the object model needs real work.   
    I'm an illustrator who also enjoys coding and Phaser must be the first engine I use where I think of a feature and hours later I have it working. It's the most frustration-free experience I've had so far. Everything has sane defaults to get you started easily and is easy to tweak once you learn how. 
    The reason there are so may requests for help on things that should be obvious is because there are many people here who've probably never coded before, or who are new to gamedev, or who are new to reading the docs and thinking for 5 minutes about a problem before posting on a forum. 
    It took me only a few minutes of reading two pages from the docs and some examples to understand how tilemaps work in phaser. If I were to build one myself I'm sure it would take me longer than that.
  19. Like
    Noid reacted to rich in Interphase - A new publication for Phaser Developers   
    When we started planning Interphase we wanted it to be a mixture of everything we love about game development. As children growing up in the 80s we were surrounded by type in listings, books full of games and cover disks brimming with content to dig through. We immersed ourselves in this fledgling technology and absorbed everything we could. It was an exciting and intoxicating time.
    Obviously things have moved on since then. You're no longer expected to laboriously copy code from newsprint quality paper. Even the concept of waiting for something to arrive in the mail is dated. As much as we both adore printed magazines, we agreed they just aren't the best format for a publication all about coding. Once you've committed to putting ink on dead trees it suddenly becomes impossible to make edits. And of course we can't embed playable games into paper pages either.
    Yet we longed to create a Phaser magazine. To create something that didn't have to conform to the traditional layout of a book (ebook or otherwise). Something containing piles of premium content that would hopefully excite a new generation of Phaser developers.
    The solution was blindingly simple. To use the best tool we had at our disposal: the web. It would allow us to bundle together all manner of Phaser related content, and to do so in an interface everyone is familiar with.
    So that's what Interphase is all about. A treasure trove of Phaser knowledge built on web technology: In-depth technical content with real deep-dives into the guts and inner workings of Phaser. Complete finished games with "Making of" guides, so you can learn the thought processes and code behind them. Then rip them apart and refashion them yourself. Tutorials that focus on single concepts and cover them well; and of course lots of great art for you to use.
    Check out the Interphase page for a list of contents and a special 15% discount available for all pre-orders.
  20. Like
    Noid got a reaction from Tilde in does anyone agree? the object model needs real work.   
    I'm an illustrator who also enjoys coding and Phaser must be the first engine I use where I think of a feature and hours later I have it working. It's the most frustration-free experience I've had so far. Everything has sane defaults to get you started easily and is easy to tweak once you learn how. 
    The reason there are so may requests for help on things that should be obvious is because there are many people here who've probably never coded before, or who are new to gamedev, or who are new to reading the docs and thinking for 5 minutes about a problem before posting on a forum. 
    It took me only a few minutes of reading two pages from the docs and some examples to understand how tilemaps work in phaser. If I were to build one myself I'm sure it would take me longer than that.
  21. Like
    Noid got a reaction from jdnichollsc in ImageLayer in Tiled   
    createLayer() is used to create tilemap layers. It won't accept an ImageLayer. However, contains an array with all your ImageLayers that you can use to add a background using ...add.Image() or ...add.Sprite()

  22. Like
    Noid got a reaction from jdnichollsc in Phaser 2.4.0 "Katar" Released   
    Does 2.4 support gamepads other than xbox 360? There is a comment in the class saying it only supports xbox 360 controllers running on chrome on windows 7, but it's more than a year old. 
  23. Like
    Noid got a reaction from ZoomBox in Easy way to improve performance and reduce draw calls   
    My game UI had three icons, each with one with a text. So in code I was adding them in what I thought was a logical way: "level" icon and text, "score" icon and text and "deaths" icon and text. 
    This resulted in phaser using a separate draw call for each one. It's not that important on desktop but on mobile every performance gain counts. 
    The fix was to simply arrange the code so that all the icons are added one after the other and then all the texts are added one after the other. Now there's only one draw call for all the icons and one for all the texts.
    This might be pretty obvious for experienced programmers but I'm sure there must be some other junior devs making the same mistake I made. 
  24. Like
    Noid reacted to qdrj in Easy way to improve performance and reduce draw calls   
    Yes, it is exposed game.renderer.clearBeforeRender = false
    I got -1 draw call and didn't notice any visual glitches. I will test this more extensively on different devices.
  25. Like
    Noid got a reaction from Tilde in Easy way to improve performance and reduce draw calls   
    I've tested it only with webgl
    There is a canvas inspector in Firefox(at least in the latest Nightly). Open the Developer Tools, click on the gear icon and add a tick on Canvas. It'll enable the canvas debugger. I couldn't find the same feature in Chrome. The same can be enabled as an experimental feature in Chrome