Jump to content

Search the Community

Showing results for tags 'leftandrightjumping'.

  • 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
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

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 1 result

  1. Hello I am new to phaser and I'm having a problem with my player who seems to not be able to jump left and right but can jump up and down when I just press the jump button. Can somebody help me? //-------------------player rendering------------------------------------- this.player = this.game.add.sprite(10, 282, 'exitar'); this.game.physics.arcade.enable(this.player, Phaser.Physics.ARCADE); this.player.body.gravity.y = 300; this.player.body.collideWorldBounds = true; this.player.anchor.setTo(0, 0); this.player.body.setSize(50, 100, 20, 0); this.game.camera.follow(this.player); this.player.animations.add('right', [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], 10, true); this.player.animations.add('left', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12], 10, true); this.player.animations.add('jump_left', [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], 7, true); this.player.animations.add('jump_right', [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47], 8, true); this.player.animations.add('win', [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65], 17, false); this.player.animations.add('still', [48, 49], 2, true); //-------------------cursor settings--------------------------------------- this.cursors = this.game.input.keyboard.createCursorKeys(); jumpButton = this.game.input.keyboard.addKey(Phaser.Keyboard.UP); left = this.game.input.keyboard.addKey(Phaser.Keyboard.LEFT); right = this.game.input.keyboard.addKey(Phaser.Keyboard.RIGHT); }, update: function () { this.game.physics.arcade.collide(this.player, this.groundLayer); this.game.physics.arcade.collide(this.player, this.stairsLayer); this.game.physics.arcade.collide(this.player, this.trash); //this.my_time(); if (state_direction) { if (left.isDown && this.player.body.blocked.down) { this.player.body.velocity.x = -100; this.player.animations.play('left'); } else if (right.isDown && this.player.body.blocked.down) { this.player.body.velocity.x = 100; this.player.animations.play('right'); } else if (jumpButton.isDown && left.isDown && this.player.body.blocked.down) { this.jumpLeft(); } else if (jumpButton.isDown && right.isDown && this.player.body.blocked.down) { this.jumpRight(); } else if (jumpButton.isDown && this.player.body.blocked.down) { this.jump(); } else if (this.game.physics.arcade.distanceToXY(this.player, 744, 510) < 92) { this.player.alpha = 0; this.train.animations.play('close') this.time.events.add(1000, this.go, this); } else { this.player.animations.play('still'); this.player.body.velocity.x = 0; } } }, jumpLeft: function () { state_direction = false; this.player.body.velocity.y = -200; this.player.body.velocity.x = -100 this.time.events.add(2000, this.my_time, this); this.player.animations.play('jump_left'); //state_direction = true; }, jumpRight: function () { state_direction = false; this.player.body.velocity.y = -200; this.player.body.velocity.x = 100; this.time.events.add(1900, this.my_time, this); this.player.animations.play('jump_right'); //state_direction = true; }, jump: function () { state_direction = false; this.player.body.velocity.y = -150; this.time.events.add(1900, this.my_time, this); //this.player.animations.play('jump_right'); },
×
×
  • Create New...