Jump to content

Search the Community

Showing results for tags 'setsize'.

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

  1. I'm trying to add a collision box to a sword swing. I'm using one sprite for the swing and rotating it 0, 90, 180, 270 degrees, depending on direction. As physics bodies are not affected by their sprite's rotation, I'm using body.setSize(width, height, offsetX, offsetY) to move the collision area depending on direction. Problem: It seems that (width, height) updates earlier than (offsetX, offsetY), or that the new offset is delayed one update. This leads to the hitbox reaching beyond the player's attack range. How can I avoid this? One way to easily test this is by calling sprite.body.setSize( <randomX>, <randomY>, <randomOffsetX>, <randomOffsetY> ). The sprite's angle does not affect this. ^ The collision area updates its size first, and later snaps to its new offset. ^ The sword sprite, 48x48. Red box indicates where the body's collision area should be.
  2. I made two maps with Tiled, start with Isometric then I have changed to Ortogonal and set the width to 32 pixels. I have a Javaascript function to read the JSON map and use "game.add.isoSprite" to show the sprites in Browser. When did I make maps with diferent sizes it didn't work in the same way. First town map (Stade 1): widh: 14 pixels height: 20 pixels this.hero.anchor.setTo( 0.5 ); Second town map Stade 2: widh: 20 pixels height: 8 pixels this.hero.anchor.setTo( 1.1 ); I set up the anchor with diferent value and then then hero walk over the map. // Set the First world size this.game.world.setBounds( 0, 0, (14+2) * 64, (20+2) * 32); this.game.physics.startSystem(Phaser.Plugin.Isometric.ISOARCADE); this.game.physics.isoArcade.bounds.widthX = 14 * 32; this.game.physics.isoArcade.bounds.widthY = 20 * 32; // Set the Second world size this.game.world.setBounds( 0, 0, (2 + 20) * 64, (2 + 8) * 32); this.game.physics.startSystem(Phaser.Plugin.Isometric.ISOARCADE); this.game.physics.isoArcade.bounds.widthX = 20 * 32; this.game.physics.isoArcade.bounds.widthY = 8 * 32; //Loop var oSprite = jogo.add.isoSprite(posX, posY, 0, imagemCarregada, qualSprite , group); oSprite.anchor.set(0.5); //hero this.hero.game.add.isoSprite(x, y, 0, loadImage, imagem , grupo); //In the First Map this.hero.anchor.setTo( 0.5 ); //In the Second Map this.hero.anchor.setTo( 1.1 ); I use a lot of values and didn't work equality in two maps. My englsh isn't good.
  3. I've noticed that "this.player.anchor.setTo(0.5);" will create a bounding box centered on the player.body in Phaser v2.2.2 when "this.game.debug.body(this.player);" is used, but in the latest Phaser v2.6.2, "this.game.debug.body(this.player);" shows a bounding box anchored at top left even if "this.player.anchor.setTo(0.5);" is previously applied. Was this an intentional change or a bug in the new version?
  4. helo. Can i change the body size in the update function? i want my player to crouch to avoid some stuff. so when i try change the player's body size in the update section the player had launched like a rocket. player1 = this.add.sprite( 100, 0, 'character'); this.physics.enable(player1, Phaser.Physics.ARCADE); player1.body.bounce.y = 0.3; player1.body.gravity.y = 1000; player1.body.maxVelocity.y = 600; player1.body.collideWorldBounds = true; player1.anchor.x = 0.5; player1.anchor.y = 1; player1.body.setSize(24, 70, 0, 0 ); player1.body.immovable = true;update: function(){ this.physics.arcade.collide(player1, layer1); //player1 controll if (player1.body.touching.down || player1.body.onFloor()) { if (this.cursors.down.isDown) { player1.body.setSize(24, 70, 0, 0); if (Math.abs( player1.body.velocity.x) > 240 && this) { player1.animations.play('roll') } else if (player1.animations.currentAnim.name != 'crouch') { player1.animations.play('crouch'); }; // console.log(player1.animations.currentAnim.name) } else if (this.cursors.left.isDown) { player1.body.velocity.x = -250; player1.scale.x = -1; player1.animations.play('run'); } else if (this.cursors.right.isDown) { player1.body.velocity.x = +250; player1.animations.play('run'); player1.scale.x = 1; } else { player1.body.velocity.x = 0; player1.animations.play('stop'); } if (this.cursors.up.isDown) { player1.body.velocity.y = -400; player1.animations.play('jump'); }; }; },
  5. Hi. I have a sprite with chained tweens. The first twenn move the x position of the sprite. And the second tween change the scale to -1.2. I do this because the sprite must turn. My problem is that the size doesn't follow correctly the sprite. This is my code. this.mummy = this.game.add.sprite(580, 406, 'mummy'); this.mummy.scale.setTo(-1.2, 1.2); this.mummy.body.gravity.y = 8; this.mummy.animations.add('walk'); this.mummy.animations.play('walk', 12, true); this.game.add.tween(this.mummy) .to({ x: 450 }, 2500, Phaser.Easing.Linear.None) .to({ x: 580 }, 2500, Phaser.Easing.Linear.None) .loop() .start(); this.game.add.tween(this.mummy.scale) .to({ x: 1.2 }, 100, Phaser.Easing.Linear.None, null, 2400) .to({ x: -1.2 }, 100, Phaser.Easing.Linear.None, null, 2400) .loop() .start(); Any idea? greetings!
×
×
  • Create New...