Jump to content


  • Content Count

  • Joined

  • Last visited

About jfhs

  • Rank

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
  1. This should throw an error because toggleSelection isn't defined and/or because the 'option' object doesn't have an 'events' property. I think what you actually meant here is 'option.button.events' instead of 'option.events'. Also, you've put the 'toggleSelection' function inside the 'option' object, so you can't just reference its property name as a variable. Instead, you need to use the reference to the 'option' object like so: option.button.events.onInputDown.add(option.toggleSelection.bind(option), this);Please note: I'm not a Phaser user, and the documentation page for events doesn't real
  2. Hi zephiraya! That's not how you create an object in JavaScript. You can use a literal to define an object like this: var button = { sprite: someSprite, correctAnswer: true, selected: false};You can write a function that creates and initializes the objects for you:function createOption (id, x, y) { var option = { id: id, button: game.add.sprite(x, y, "option" + id), selected: game.add.sprite(x, y, 'selected') }; option.button.anchor.set(0.5); option.selected.anchor.set(0.5); option.button.inputEnabled = true; option.selected.visi
  3. jfhs

    visual studio code

    @shohan4556: Visual Studio Code just recently added the possibility for extensions, so I don't think there's anything specifically for Phaser available yet. Here's the marketplace for VS Code extensions: https://marketplace.visualstudio.com/#VSCode Here's some information on how to write extensions if you'd like to roll your own: https://code.visualstudio.com/docs/extensions/example-hello-world
  4. jfhs

    visual studio code

    I've been using VS Code for some months now and I'm quite happy with it. I used Brackets before that but it was rather sloppy even on my quite fast machine, a problem VS Code doesn't have. Also, VS Code's IntelliSense is much smarter than anything I've ever seen in Brackets, and the linter finds type-related bugs even if you don't use TypeScript (although it does have some "false positives" sometimes). I'm certainly not a Microsoft fan (have been using linux as my main OS since at least 2006) but even I had to admit that VS Code is quickly becoming one of the best editors for JavaScript stuf
  5. Hi IHateThisMap! You are passing no "this" context to .forEach(), but use "this" in the callback. Does it work if you change it as follows? Look at the last line here: group.forEach(function(enemy) { enemy.animations.add('fly', [0], 20, true); enemy.animations.add('hit', [0, 1, 0, 1, 0, 1, 0], 20, false); enemy.events.onAnimationComplete.add(function(e) { e.play('fly'); }, this); }, this);In JavaScript, a function defined inside another function doesn't automatically have the parent function's "this" reference. If you
  6. You can use JavaScript objects as namespaces or use a module system. If you go the namespace route, you'll have one global object containing the parts of your application. Your gui.js file could then look like this for example: if (typeof GAME === "undefined") { var GAME = {};}GAME.gui = (function () { // define some GUI functions here function doSomeGuiStuff () { GAME.other.doSomeStuff(); // ... } return { // Put the functions you want to be "public" into this object: doSomeGuiStuff: doSomeGuiStuff };}());This approach uses only one glob
  7. Awesome graphics, really nice job! Performance could be better (Core i7 Quad + 16 GB Ram + some onboard graphics chip, Chromium). Unfortunately, the fonts are not readable for me (see attachment). There also is a bug: When I start the game I cannot use the arrow keys to move the screen. It only works after using WASD first... Hope that helps!
  8. I think there's an important distinction to make here: There's libraries on the one hand and frameworks on the other. A library is something you use in your code so that you don't have to do something yourself (or do it again), but it doesn't dictate how you have to write your code. Frameworks are similar to libraries, but they force you to make compromises in how you structure your code. Therefore, frameworks can lead to something called "lock-in". This means that if you later decide, for whatever reason, that you want to use another framework, you'll have to rewrite pretty much all of your
  9. No, I actually don't use ES6 yet. Why? Because I don't need most of the features it adds. Classes? It's just another syntax for what you can already do. Promises? I already use those with a shim. Tail-call optimization? I won't get this from a transpiler... And the few other things I'd like to use from ES6 (default arguments, arrow functions etc.) are not important enough for my taste to justify the added complexity of using a transpiler.
  10. In JavaScript, you could just do this: var house1 = { living_room: { chair: new Chair(), chair2: new Chair() }};Although your example raises the question why you don't just use an array if you have more than one thing of the same "type", as is the case with your chairs: var house1 = { living_room: { chairs: [new Chair(), new Chair()] }}
  11. If you want to use something like: var leaderBoard = new LeaderBoard(containerElement, "/my-leader-board-content/");You have to create a "class" that abstracts away the details of requesting the leaderboard data: // This example assumes you are using jQuery for the AJAX request, but you// can use any other library for this or even roll your own with XMLHttpRequest.function LeaderBoard (parent, url) { // Create an element to contain the leaderboard: this._container = document.createElement("div"); // Add it to the parent element: parent.appendChild(this._container); /
  12. As a rule of thumb, that is correct. That's only an issue if you actually need to remove the listener, though. For most games you'll want the resizing to take place for as long as the page exists. In this case it doesn't make an awful lot of sense to assign the listener to a variable. It's ok to break these rules of thumb if it doesn't mean you sacrifice readability or increase the chances for hard-to-find bugs. You could also argue that in this case assigning this listener to a variable would violate YAGNI (You Ain't Gonna Need It) and/or KISS (Keep It Simple, Stupid).
  13. Uncaught ReferenceError: MO5 is not defined(anonymous function) @ StageResizer.js:3Sorry, I just saw your question now. The reason you get this error is because the code snippet used my library's module system which you can find here: https://github.com/iiyo/MO5.js I updated the gist so that it works without the module system. By the way, what you wrote in your post is not the code I suggested. If you look closely, I used "myStageResizerInstance" which obviously is an instance of the StageResizer constructor, not a canvas element or anything like that.
  14. @xerver: Yes, sniffing was my solution as well. Now I'm a little confused whether I should take it out again, I probably should. I guess something just went wrong on my device, maybe the graphics unit was on vacation or something, who knows. But it seems to run pretty well either way. @Mat: Good to know it works so well there, thanks for the heads up! Awesome!
  15. Hi xerver, there once was an emulator for Kindle Fire devices but it has been discontinued. It never supported the Silk browser though, so it wouldn't have been of much help either, I'm afraid. I just tried running the Khronos WebGL conformance tests in Silk and it tells me the browser doesn't support WebGL at all and refuses to run any further tests. If that's the case, maybe you should check out how their test differs from the auto-detect in pixi? In Aurora the tests kind of work, but then the browser always tells me that a script is causing the page to be slow and the whole screen bec
  • Create New...