Jump to content

Search the Community

Showing results for tags 'ledge'.

  • 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 2 results

  1. mbspringer133

    var ledge

    the only change made is the label name? var ledge = HORIZ_.create(50, 50, 'VERT_400'); ledge.body.immovable = true; // LEFT MOST VERTICAL var ledge = VERT_.create(50, 50, 'VERT_400'); ledge.body.immovable = true; // LEFT MOST VERTICAL var newname = HORIZ_.create(50, 50, 'VERT_400'); ledge.body.immovable = true; // LEFT MOST VERTICAL https://youtu.be/hdvo3_j8hMU myPit.html
  2. Here is my preload function function preload() { game.load.atlas('soldier1', 'assets/spritesheets/soldier4_full.png', 'assets/spritesheets/soldier4_full.json', Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); game.load.image('desert', 'assets/images/desert.png'); game.load.image('desert_ledge', 'assets/images/desert_ledge.png');} And this is create function create() { game.physics.startSystem(Phaser.Physics.ARCADE); map = game.add.sprite(0, 0, 'desert'); // The platforms group contains the ground and the 2 ledges we can jump on platforms = game.add.group(); platforms.enableBody = true; ledges = [ [0.5, 0.6, 70, 499], [0.5, 0.6, 330, 499], [0.5, 0.6, 600, 499], [0.8, 0.6, 290, 274], [0.5, 0.6, 150, 389], [0.5, 0.6, 500, 389], [0.5, 0.6, 500, 163], [0.5, 0.6, 150, 163], ]; ledges.forEach(function(info){ var ledge = platforms.create(info[2], info[3], 'desert_ledge'); ledge.body.immovable = true; ledge.scale.setTo(info[0], info[1]); }); player = game.add.sprite(50, 150, 'soldier1'); player.anchor.setTo(.5, .5); player.enableBody = true; game.physics.arcade.enable(player); // Player physics properties. Give the little guy a slight bounce. player.body.bounce.y = 0.2; player.body.collideWorldBounds = false; //player.body.setSize(player.body.width*0.7, player.body.height); player.frameName = 'Idle__000.png'; setAnimations(); player.animations.play('walk'); player.body.gravity.y = 700; cursors = game.input.keyboard.createCursorKeys();}Finally here is update function update() { game.physics.arcade.collide(player, platforms, null, function(player, ledge){ if(cursors.down.isDown) { console.log('down'); return false; } if(player.body.velocity.y < 0) return false; return true; }, this); // Reset the players velocity (movement) player.body.velocity.x = 0; if (cursors.left.isDown) { // Move to the left player.body.velocity.x = -150; if(player.scale.x > 0) { player.scale.x *= -1; } if(player.body.touching.down) player.animations.play('walk'); } else if (cursors.right.isDown) { if(player.scale.x < 0) { player.scale.x *= -1; } // Move to the right player.body.velocity.x = 150; if(player.body.touching.down) player.animations.play('walk'); } else { if(player.body.touching.down) player.animations.play('idle'); } if (cursors.up.isDown && player.body.touching.down) { player.body.velocity.y = -420; player.animations.play('jump'); }}Now When I start the game there is a space between player and ledge which i don't want to exist If i change spritesheet to another atlas space reduces I think this is not about atlas files because when i debug sprites it seems that character doesn't have any padding. So how can i get rid of this problem ? Where am i missing ? Thanks in advance.
×
×
  • Create New...