georgejfrick

Members
  • Content Count

    34
  • Joined

  • Last visited

About georgejfrick

  • Rank
    Advanced Member

Contact Methods

  • Twitter
    brewcitycoder
  1. Hey sorry to revive a really old topic; but since I created it and it's not resolved I wanted anyone who searched to find an answer.. 1) The most likely problem in these cases is not using the out and up frames as the same. A button will sit on its 'up' frame if it's been clicked, as specified. For many of my activities; I was able to go back and fix this by correctly specifying the same frame for up and out. 2) When this wasn't the case, I recreated the button(s); which isn't that hard. 3) Create a custom button sprite; you can use the existing Button class as a guide but modify how it changes frames.
  2. I have tried that. We've had to start mixing down the audio, it also doesn't answer the question of what the parameter is for even if "this.gameSounds.volume" worked.
  3. This always seems to bother people. It's just a safety habit; I expect to see an IIFE when I open a javascript file...
  4. I use Browserify, basejs, and Grunt to make basic classes/modules in Phaser. Here is an example: /** * @author George Frick * @version 1.0.0 * @creation 09/21/2015 * Draw a loading screen in Phaser. Expects resources to already be loaded. */(function () { 'use strict'; var Base = require('basejs'); var LoadingScreen = Base.extend({ constructor: function (game, settings) { if (!settings || !settings.loading_image_key || !settings.loading_bg_color || !settings.loading_text || !settings.loading_font ) { throw "Loading screen is missing a required configuration field."; } this.game = game; this.settings = settings; }, show: function () { // 1. Create solid background. this.bgColor = this.game.add.graphics(0, 0); this.bgColor.beginFill(this.settings.loading_bg_color); this.bgColor.drawRect(0, 0, this.game.world.width, this.game.world.height); this.bgColor.endFill(); // 2. Create a loading image/icon/splash this.splashImage = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, this.settings.loading_image_key); this.splashImage.y -= this.splashImage.height; this.splashImage.anchor.setTo(0.5, 0.5); // 3. Add a progress indicator this.progress = this.game.add.text(this.game.world.centerX, this.game.world.centerY, this.settings.loading_text + "0%", this.settings.loading_font); this.progress.anchor.setTo(0.5, 0.5); this.game.load.onFileComplete.add(this.fileComplete, this); }, destroy: function () { this.splashImage.cropEnabled = false; this.splashImage.destroy(); this.splashImage = null; this.bgColor.destroy(); this.bgColor = null; this.progress.destroy(); this.progress = null; this.game.load.onFileComplete.removeAll(); }, fileComplete: function (progress, cacheKey, success, totalLoaded, totalFiles) { this.progress.text = this.settings.loading_text + progress + "%"; } }); module.exports = LoadingScreen;}());I have a full working game example of this on GitHub: https://github.com/georgefrick/PhaserJsDemoGame You can pull it down and build it with Grunt, it's a full working game. Each state is made as a module, so it gives you a base to start from.
  5. You could skip even more manual steps by using texture packer, which will generate the JSON for you. All they have to do is open up the texture packer project, change the image and click 'publish', the new JSON file and new art file will be created.
  6. /** * * Draw a loading screen in Phaser. Expects resources to already be loaded. * Generally used in preload and main states, with resources loaded during boot. */(function () { 'use strict'; var Base = require('basejs'); var LoadingScreen = Base.extend({ constructor: function (game, settings) { if (!settings || !settings.loading_image_key || !settings.loading_bg_color || !settings.loading_text || !settings.loading_font ) { throw "Loading screen is missing a required configuration field."; } this.game = game; this.settings = settings; }, show: function () { // 1. Create solid background. this.bgColor = this.game.add.graphics(0, 0); this.bgColor.beginFill(this.settings.loading_bg_color); this.bgColor.drawRect(0, 0, this.game.world.width, this.game.world.height); this.bgColor.endFill(); // 2. Create a loading image/icon/splash this.splashImage = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, this.settings.loading_image_key); this.splashImage.y -= this.splashImage.height; this.splashImage.anchor.setTo(0.5, 0.5); // 3. Add a progress indicator this.progress = this.game.add.text(this.game.world.centerX, this.game.world.centerY, this.settings.loading_text + "0%", this.settings.loading_font); this.progress.anchor.setTo(0.5, 0.5); this.game.load.onFileComplete.add(this.fileComplete, this); }, destroy: function () { this.splashImage.cropEnabled = false; this.splashImage.destroy(); this.splashImage = null; this.bgColor.destroy(); this.bgColor = null; this.progress.destroy(); this.progress = null; this.game.load.onFileComplete.removeAll(); }, fileComplete: function (progress, cacheKey, success, totalLoaded, totalFiles) { this.progress.text = this.settings.loading_text + progress + "%"; } }); module.exports = LoadingScreen;}());I use this like this: (function () { 'use strict'; var Base = require('basejs'), LoadingScreen = require('../loading-screen'); var PreloadState = Base.extend({ constructor: function (settings) { if (!settings ) { throw "Preload state is missing a required configuration field."; } this.settings = settings; }, preload: function () { this.loadingScreen = new LoadingScreen(this.game, this.settings); this.ready = false; this.loadingScreen.show(); // Do all of your 'real' asset loading here! this.something.preload(); }, create: function () { this.loadingScreen.destroy(); }, update: function () { if ( this.something.isPreloadComplete() && this.ready === false) { this.ready = true; // go to menu or play state, or whatever } } }); module.exports = PreloadState;}());
  7. I believe when you switch states, everything is lost. The audio object should be gone and need to be re-added. I think the bug here is that the audio doesn't get stopped (what browser are you experiencing this in?)
  8. You always reply to posts like these, but I have a half a dozen posts with serious technical questions about Phaser and they constantly go ignored. I'm struggling trying to use Phaser in professional projects and seeing this pattern is frustrating. Is there something I can do to get better support, or are my posts not well timed?
  9. Most of the games I've built with Phaser have been reproductions of board games with an educational edge to them (ex: monopoly, but the chance cards are questions the students answer). With these games; I've unit tested by making sure the Phaser portion of the game represents a strong 'model'. I'll usually divide the model up into the data ("QuestionSet"), and the representation of the game state ("GameBoard", not phaser states; which I'm using less and less). These non-Phaser components can be easily tested with Jasmine and even allow me to TDD them by writing out statements about them ("The board should return a winner"). It then comes down to making sure Phaser represents the game state and not letting game logic slip into Phaser code. When it comes to Phaser itself, I'm not as interested in unit testing, but I find the discussion fascinating. My lack of interest is due to the difficulty testing on all platforms/etc. I mostly user test with "Phaser Inspector" to help. It will be interesting to see what people post in addition to the already good posts.
  10. My attempt to control the volume when adding the marker did not make any difference, so I am still looking for both how to control volume, and what exactly that parameter is for...
  11. Hello, I'm finding no difference between these two lines: // Should be 1/10 volume?this.gameSounds.play( "auditorium_applause_big_06", 0, 0.1, false, true);// Should be full volumne?this.gameSounds.play( "auditorium_applause_big_06", 0, 1.0 , false, true);Can volume not be controlled, or is this the wrong input to this parameter? I need to play two sounds at once (well, three); and have the background sound playing quieter. Am I forced to modify the source sound? The above code is using a single sound with markers, initiated this way: this.gameSounds = this.game.add.audio(this.theme.soundKey); this.gameSounds.allowMultiple = true; _.each( this.theme.sounds, function( timing, key ) { this.gameSounds.addMarker(key, timing[0], timing[1], 1, timing[2]); }, this); // this.gameSounds.onMarkerComplete.add(this.onSoundFinished, this); // This event seems broken. this.gameSounds.onStop.add(this.onSoundFinished, this);Hrm, now I'm wondering if I have to control the sound when I add the marker? I'm going to try that and I'll reply to my own post if it works.
  12. Yes. I don't try to reload in the fileError method, I find that this works: 1. In your preload method: this.game.load.onFileComplete.add(this.fileComplete, this);1. In your handler, you can use this to both update your progress bar and: fileComplete: function (progress, cacheKey, success, totalLoaded, totalFiles) { if( success ) { this.progress.text = "Loading: " + progress + "%"; } else { log.debug("Retrying key " + cacheKey); this.game.load.audio(cacheKey, this.cacheTemp[cacheKey] ); }},I found that this reloaded everything. However, it doesn't fix audio randomly not playing or 'starting late'. If you find a comprehensive IE audio solution, I'd love to hear it. We tried this and ended up switching back to loading a single audio file with markers. They both work poorly in IE, but with the markers we get great performance everywhere else.
  13. https://jsfiddle.net/5qzjjegt/6/ I did not try the dev build, I'm not sure i want to put a dev build into my client's production system?
  14. No editing needed, when I click the button the text stays as "pointer over: true" but I made this: https://jsfiddle.net/5qzjjegt/4/ Click button 1 - button hides, text remains "pointer over: true", click second button. Now both say "pointer over: true", but you are over the right button. It works perfectly until you click one of them.
  15. Yeah I tried firing the event myself with no luck. I've tried swapping the frames for my toggle buttons (like mute), but the behavior is still unacceptable. 1) If you hide/re-use a button, it stays in the mouse over state, and the cursor stays the pointer. I'm getting around this by deleting the button when they click it (destroy). 2) If it is a toggle button (implemented multiple ways, both swapping buttons and swapping frame sets); when you swap it, and even if you try to force it (setFrames, then setFrame); it revers to the mouse-out image and normal cursor. So in both cases it is the opposite affect of what it should be and I'm unable to find a work around that doesn't consist of 'stop using button'.