haden Posted August 17, 2013 Share Posted August 17, 2013 I've been using Phaser for more than a week now, making my first polished Html5 game. I have a good experience with Flixel, so I was looking forward to using Phaser. Yesterday I upgraded to 1.00TS083. I will try to post here all the problems, suggestions and even small fixes I've found. Overall, I've been pretty pleased with the framework. Getting something up and running on my iPod touch was relatively easy and the performance is good enough. I am sticking to 320x480 for now and the graphics scale really well on mobile. The various examples available with Phaser are really helpful and in general are enough to learn how to use the engine, although it's not uncommon to jump into Phaser's code just to get a better understanding of how things work. In the next posts I will point to some things I think are missing or incorrect in the engine. Link to comment Share on other sites More sharing options...
haden Posted August 17, 2013 Author Share Posted August 17, 2013 In time/TimeManager.ts, the attribute elapsed doesn't seem to be updated at all. The most obvious workaround is to just use TimeManager.elapsedSince(). Link to comment Share on other sites More sharing options...
haden Posted August 17, 2013 Author Share Posted August 17, 2013 To switch state, I just use Game.switchState(NewState) which works fine. But sometimes I want to submit an object instead of a class, for example in my game when the player clicks on a level button, I want to pass the level number to the PlayState like this:this.game.switchState(new PlayState(this.game, this.nextLevelNum));This doesn't work. When I looked at Game.switchState() I noticed that the attribute this.state isn't affected if the passed state isn't a function. I just changed this (inside Game.switchState() ):// Prototype?if (typeof state === 'function'){ this.state = new state(this);} to this:// Prototype?if (typeof state === 'function'){ this.state = new state(this);}else{ this.state = state;}and now the first code example works just fine. Link to comment Share on other sites More sharing options...
haden Posted August 17, 2013 Author Share Posted August 17, 2013 I am using DynamicTexture to draw custom sprites from multiple frames/sprites (using DynamicTexture.pastImage). It's works just fine but it doesn't seem to support spritesheet frames nor atlases. Link to comment Share on other sites More sharing options...
haden Posted August 22, 2013 Author Share Posted August 22, 2013 in the current version I am using (1.00TS083), I think there is a bug in the orientationScreen. Basically my game is only playable in portrait orientation and I want to display an image, with key 'please-rotate', if the player holds it's device in landscape orientation. What I did is to call:game.stage.enableOrientationCheck(false, true, 'please-rotate');and it looks like this:public enableOrientationCheck(forceLandscape: bool, forcePortrait: bool, imageKey: string = '') { this.scale.forceLandscape = forceLandscape; this.scale.forcePortrait = forcePortrait; this.orientationScreen.enable(forceLandscape, forcePortrait, imageKey); ...}but this didn't work. After some investigations I found this Phaser/system/screen/OrientationScreen.ts:public enable(onLandscape: bool, onPortrait: bool, imageKey: string) { this._showOnLandscape = onLandscape; this._showOnPortrait = onPortrait; this.landscapeImage = this.game.cache.getImage(imageKey); this.portraitImage = this.game.cache.getImage(imageKey);}public render() { if (this._showOnLandscape) { this.game.stage.context.drawImage(this.landscapeImage, ...); } else if (this._showOnPortrait) { this.game.stage.context.drawImage(this.portraitImage, ...); }}So basically, OrientationScreen if enabled has one single image that will be displayed either when the game is in landscape or in portrait orientation. What's wrong is that Stage.enableOrientationCheck() is calling OrientationScreen.enable() with the wrong parameters, basically it should be:this.orientationScreen.enable(forcePortrait, forceLandscape, imageKey);instead of:this.orientationScreen.enable(forceLandscape, forcePortrait, imageKey);just swapping those two parameters fixed the problem for me. Link to comment Share on other sites More sharing options...
rich Posted August 25, 2013 Share Posted August 25, 2013 Thanks for starting this thread, it's really useful reading. Some things: 1) In TimeManager use the delta value for the ms elapsed since the last frame. I will probably remove 'elapsed' (or swap 'delta' for 'elapsed'). 2) Good catch on switchState, have added 3) I've updated OrientationScreen as actually most of the code in there was pointless, so it's much smaller as a result now and works as you expect. Atlas support for DynamicTextures is on the todo list. Link to comment Share on other sites More sharing options...
PKrawczynski Posted August 26, 2013 Share Posted August 26, 2013 3) I've updated OrientationScreen as actually most of the code in there was pointless, so it's much smaller as a result now and works as you expect. Im not so sure about 3rd point as there are 2 cases ive encountered when using SHOW_ALL scale mode:1. start game in lanscape, rotate to portait. Result: "rotate game" image is shown correctly, fits whole screen by stretching2. start game in portrait Result: "rotate game" image is shown incorrectly as it isnt stretched to fullscreen. Additionaly in case 2 after I rotate to landscape, and rotate once again to portrait - it is properly scaled and stretched on whole screen. Link to comment Share on other sites More sharing options...
Recommended Posts