hpcodecraft

Members
  • Content Count

    15
  • Joined

  • Last visited

About hpcodecraft

  • Rank
    Member

Contact Methods

  • Twitter
    hpcodecraft

Recent Profile Visitors

694 profile views
  1. Hi Rich, I wasn't sure if it was my fault or a problem with the engine so I didn't create an issue, but I've done that now: https://github.com/photonstorm/phaser/issues/512 Thank you for your support!
  2. Hi everyone, when scaling the world the camera follow and fixing groups to the camera seems to stop working. Please see the live example here: http://phasercamera.hpcodecraft.me/ Holding down the right arrow key makes the mushroom leave the screen and the camera does not follow. Also, the UI at the top starts to wander off screen. If globalScale is set to 1 everything works as expected. Any ideas?
  3. Hi Rich, thank you for your answer and the update! I'll try the new build now – and next time rebuild myself
  4. Is it possible that the new ScaleManager and StateManager aren't included in the latest build at github? My game doesn't run anymore because the states can't be started (this.state is undefined). Also, how can I build Phaser from the source? Tried to run build/build.php in my browser from a cloned repo but the output file is only 288 bytes in size..
  5. Hi, this hopefully will be available in 1.2 - see Richs post here: http://www.html5gamedevs.com/topic/2898-pause-menu/?p=18774
  6. I have an idea how it can be done but I'm stuck again - I want to have one group that contains all platforms above the player (no collision) and below the player (with collision). When the player jumps, platforms will be shifted to the corresponding group. Unfortunately, I can't get it to work - here's the basic code: var Level = function(state) { var self = this; this.platforms = { above: state.add.group(), below: state.add.group() }; // this.data is loaded from a JSON file and contains the platform coordinates and textures this.data.platforms.forEach(function(data, i) { tempSprite = self.platforms.above.create(data.x, data.y, data.texture); tempSprite.body.immovable = true; });};Level.prototype.constructor = Level;// called in the state update functionLevel.prototype.update = function(player) { var y = player.body.bottom; // move platforms to colliding group var shiftPlatform = function(platform) { if(platform.y > y) { this.platforms.above.remove(platform); // generates error // this.platforms.below.add(platform); //console.log(this.platforms, platform); // works if line above is commented out } }; this.platforms.above.forEachAlive(shiftPlatform, this);};With this code it produces this error Uncaught TypeError: Cannot read property 'alive' of null The group iteration fails as soon as the group is modified - if only the console.log statement is left it works without error and all variables are logged correctly. I've been trying this for two days now in different combinations (regular for-loop, group.forEach, group.iterate) and nothing worked. What am I doing wrong here?
  7. Hi everyone! I want to create an Icy Tower like game where the player has to jump upwards over a series of platforms. How can I achieve that the player can jump through a platform that is above and then land on it? I had a look at Physics.Arcade.Body.checkCollision but it seems not to do what I intend. My platforms and the player are all Phaser.Sprite instances (no tilemaps).
  8. I think you did not add the sprite to the game - try inserting game.add.existing(this);after your Phaser.Sprite.call in the create function
  9. You can try this: var MyButton = function(game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group) { Phaser.Button.call(this, game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group); game.add.existing(this);};MyButton.prototype = Object.create(Phaser.Button.prototype);MyButton.prototype.constructor = MyButton;MyButton.prototype.activate = function() { this.input.enabled = true; this.frame = 0;};MyButton.prototype.deactivate = function() { this.input.enabled = false; this.frame = 2; // change this to match your greyed out frame in the button spritesheet};Usage: var button = new MyButton(game, 0, 0, 'button-sprite', buttonCallback, this);button.deactivate();button.activate();
  10. Have you tried using this.game instead of game?
  11. I just solved it by changing var button = new ScaledButton(this, 2, 146, 'button-texture', doSomething, this, 0, 0, 0);to var button = new ScaledButton(this.game, 2, 146, 'button-texture', doSomething, this, 0, 0, 0);I guess it's because I'm in a State so this is the State object and not the Game object. With my ScaledSprite class (which is basically the same, only extending Phaser.Sprite) it works the first way, though.
  12. I'm using 1.1.5 and just tried 1.1.4 again, with the same results. I'm also using that template you pointed to - here's my scaling code from Boot.js: create: function() { Phaser.Canvas.setSmoothingEnabled(this.game.context, false); // Unless you specifically know your game needs to support multi-touch I would recommend setting this to 1 this.game.input.maxPointers = 1; // Phaser will automatically pause if the browser tab the game is in loses focus. You can disable that here: this.game.stage.disableVisibilityChange = true; if(this.game.device.desktop) { // If you have any desktop specific settings, they can go in here this.game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL; //resize your window to see the stage resize too this.game.stage.scale.pageAlignHorizontally = true; this.game.stage.scale.pageAlignVertically = true; this.game.stage.scale.refresh(); } else { // mobile settings } // By this point the preloader assets have loaded to the cache, we've set the game settings // So now let's start the real preloader going this.game.state.start('Preloader'); }I'm using the scaled sprites to scale the coordinates of the sprite automatically, too. My game is 320x180 pixels and with the autoscaling sprites I can position a sprite e.g. at x: 10 and y: 10 in my code and it will always be at the same place on screen, no matter if the user is on a phone or a 40" TV. At least that's what I'm trying to achieve but I'm quite new to Phaser, so maybe there's a better way to do that For the error thrown to my console: It seems that this.game.canvas is not known in the button's inputHandler, this is the line from phaser.js: this.game.canvas.style.cursor = "default";
  13. Hi everyone! I want to extend Phaser.Button to make it scale automatically upon creation. Therefore I've got a global variable SCALE which contains the game's scale factor. I've done the same with Phaser.Sprite already and it works fine, but it seems I can't get it right with the buttons. Here's my ScaledButton.js: var ScaledButton = function(game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group) { x*= SCALE; y*= SCALE; Phaser.Button.call(this, game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group); this.scale.setTo(SCALE, SCALE); game.add.existing(this);};ScaledButton.prototype = Object.create(Phaser.Button.prototype);ScaledButton.prototype.constructor = ScaledButton;In my Game state, I create it like so: var button = new ScaledButton(this, 2, 146, 'button-texture', doSomething, this, 0, 0, 0);The button is created and added to the stage, but on mouseover/mouseout it throws the following error into my Chrome console: Uncaught TypeError: Cannot read property 'style' of undefined [phaser.js:17276]Any ideas? Oh, and an additional "best pratice" question: In my extended class, I add the object directly by game.add.existing(this). Is this a good practice or should this be handled outside the class definition?
  14. Hi Rich, thanks for the quick reply – I'll keep those lines commented out then for now
  15. Hello, I just upgraded from 1.1.3 to 1.1.4 and now I'm having some trouble with getting the crisp rendering working again. In my boot state, I use Phaser.Canvas.setSmoothingEnabled(this.game.context, false);This worked great in 1.1.3 but now it doesn't anymore. My sprites are all being scaled on creation and this somehow seems to reset the imageSmoothing. After some digging in the phaser code I commented out this command which appears in line 3292 and 45549 of phaser.js: context[this.smoothProperty] = (this.scaleMode === PIXI.BaseTexture.SCALE_MODE.LINEAR);Now the pixels are all crisp again but I have no idea of possible side effects and I want to avoid modifying the phaser core. Any thoughts?