Search the Community

Showing results for tags 'blocked'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 3 results

  1. HI all, I am new to Phaser and am so far having fun After finishing the "creating your first game" tutorial I started extending the project, but i am having trouble with 'body.blocked' functionality - both left and right are always false, even though my character is walking into the wall repeatedly. Here I am registering collision between the player and my wall tiles: game.physics.arcade.collide(player, walls);Immediately after this, I do a simple check to see if i cannot move left or right anymore: if (player.body.blocked.left || player.body.blocked.right) However, both the left and right booleans are always false, and my character continues to walk into the wall. Does anyone have any suggestions how I might be able to fix this? Thanks, Jamie
  2. In a platformer game, when using the Arcade mode, body.blocked.down is true when you are stepping on the world boundary (like in the platformer example) on when on tile ground. But when standing on another sprite (for example a sprite for the floor with body.immovable = true) it currently shows body.blocked.down as false, but body.touching.down true. I have a demo for a basic platformer, to implement the jump functionality I want to test for blocked, because if I test for touching.down then the character also jumps when touching non-blocking elements (that overlap not colllide). So my question is, is this the expected behavior for body.blocked? how could I just test just for blocking objects to implement jump? Game: http://static.pablofarias.com/blocked-down/ //this game will have only 1 statevar GameState = { //load the game assets before the game starts preload: function() { this.game.load.image('ground', 'assets/images/ground.png'); this.game.load.image('platform', 'assets/images/platform.png'); this.game.load.image('player', 'assets/images/player.png'); this.game.load.image('fire', 'assets/images/fire.png'); this.game.load.image('goal', 'assets/images/goal.png'); }, //executed after everything is loaded create: function() { //adapt to screen size, fit all the game this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.setScreenSize(true); //init physics system this.game.physics.startSystem(Phaser.Physics.ARCADE); //floor this.ground = this.game.add.sprite(0, 569, 'ground'); //enable physics properties (the floor wont move) this.game.physics.arcade.enable(this.ground); this.ground.body.immovable = true; //level data. location of elements var levelData = { platformData: [ {x: 0, y: 430}, {x: 90, y: 290}, {x: 0, y: 140} ], fireData: [ {x: 200, y: 539}, {x: 60, y: 400}, {x: 190, y: 400}, {x: 180, y: 260}, {x: 300, y: 260}, {x: 200, y: 110} ] }; //group to keep all the hard platforms this.platforms = this.game.add.group(); //enable physics properties this.platforms.enableBody = true; //create each platform var self = this; var platform; levelData.platformData.forEach(function(element){ platform = self.platforms.create(element.x, element.y, 'platform'); //we don't need to enable body on each element, as we enabled body for the entire group, so body will be present here platform.body.immovable = true; }); //group for fire this.fires = this.game.add.group(); this.fires.enableBody = true; //create fire var fire; levelData.fireData.forEach(function(element){ fire = self.fires.create(element.x, element.y, 'fire'); }); //create goal this.goal = this.game.add.sprite(20, 90, 'goal'); this.game.physics.arcade.enable(this.goal); //create player this.player = this.game.add.sprite(20, 535, 'player'); this.game.physics.arcade.enable(this.player); this.player.body.gravity.y = 1000; //don't leave the world boundaries this.player.body.collideWorldBounds = true; //arrow keys this.cursors = this.game.input.keyboard.createCursorKeys(); }, update: function() { //the player collides with the ground and platforms this.game.physics.arcade.collide(this.player, this.ground); this.game.physics.arcade.collide(this.player, this.platforms); this.game.physics.arcade.overlap(this.player, this.fires, this.burn, null, this); this.game.physics.arcade.overlap(this.player, this.goal, this.win, null, this); //platformer controllers this.player.body.velocity.x = 0; if(this.cursors.left.isDown) { this.player.body.velocity.x = -350; } else if(this.cursors.right.isDown) { this.player.body.velocity.x = 350; } if(this.cursors.up.isDown && this.player.body.blocked.down) { this.player.body.velocity.y = -550; } }, //burn player burn: function(player, fire) { console.log('auch!'); }, //win the game win: function() { console.log('you win'); }, render: function() { this.game.debug.bodyInfo(this.player, 0, 100); }};//initiate the Phaser frameworkvar game = new Phaser.Game(750, 640, Phaser.AUTO);game.state.add('GameState', GameState);game.state.start('GameState');
  3. I am having problems jumping in my game. 1st. I use key.isDown to determinate the jump of my sprite. But if I hold key of the jump, my character is jumping all the time. I want to push the key once and wait to another key press to do a new jump. 2nd. I draw the map with json using a file made by tiled. This tiles work with sprite.touching, they are not work by sprite.blocked. Then in my game I draw new blocks with sprite.create function and they work with sprite.blocked only. What is the difference? By the way I have some problems with sprite collisions in this new blocks, I can stick to the walls like this while hold left cursor. I have Phaser v2.0.5.