Jump to content

Search the Community

Showing results for tags 'collision sprite group proble'.

  • 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 have a problem to make collision between 2 sprites works. I use P2 physics system and my main sprite is a player and the other sprite is also player but they are loaded after (it's a multi player game). Init of the map : this.game.stage.backgroundColor = '#2f8136'; this.map = this.game.add.tilemap('map'); // Preloaded tilemap this.map.addTilesetImage('grass'); // Preloaded tileset this.map.addTilesetImage('treetop'); // Preloaded tileset this.map.addTilesetImage('trunk'); // Preloaded tileset this.map.addTilesetImage('watergrass'); // Preloaded tileset this.layerBackground = this.map.createLayer('background'); // This is the default name of the first layer in Tiled this.layerBackground.resizeWorld(); // Sets the world size to match the size of this layer. this.layerForeground = this.map.createLayer('foreground'); // This is the default name of the first layer in Tiled this.layerForeground.resizeWorld(); // Sets the world size to match the size of this layer. this.layerTop = this.map.createLayer('top'); // This is the default name of the first layer in Tiled this.layerTop.resizeWorld(); // Sets the world size to match the size of this layer. this.map.setCollisionBetween(1, 300, true, 'foreground');Init of the game : this.game.world.setBounds(0, 0, 2000, 2000); //Permet de definir la taille et les bords de la carte this.game.physics.startSystem(Phaser.Physics.P2JS); this.game.physics.p2.setBoundsToWorld(true, true, true, true, false);this.game.physics.p2.updateBoundsCollisionGroup();Init of collision group : playerCG = this.game.physics.p2.createCollisionGroup();Init of player (create) : this.sprite = this.game.add.sprite(200, 200, 'player'); //Definition de l'echelle : this.sprite.scale.x = 0.9; this.sprite.scale.y = 0.9; //Definition des animations : this.sprite.animations.add('left', [9, 10, 11, 12, 13, 14, 15, 16, 17], 20, true); this.sprite.animations.add('right', [27, 28, 29, 30, 31, 32, 33, 34, 35], 20, true); this.sprite.animations.add('up', [0, 1, 2, 3, 4, 5, 6, 7, 8], 20, true); this.sprite.animations.add('down', [18, 19, 20, 21, 22, 23, 24, 25, 26], 20, true); //On active le physic sur le sprite (permet d'utiliser fixedRotation....) this.game.physics.p2.enable(this.sprite); this.sprite.body.setRectangle(22, 7); //permet de redefinir la taille du body du perso(util pour les collisions par ex) this.sprite.anchor.setTo(0.5, 0.95); //permet de redifinir la position du sprite this.sprite.body.fixedRotation = true; //permet de fixer la rotation du perso (cela arrive en bordure de terrain que le perso tourne sur lui meme !) this.sprite.body.setZeroDamping(); this.sprite.id = index; //Permet de prendre en charge le clavier : this.cursors = this.game.input.keyboard.createCursorKeys(); //Gestion des collisions : this.sprite.body.setCollisionGroup(playerCG); this.sprite.body.collides([levelCG, playerCG]); this.game.physics.p2.updateBoundsCollisionGroup();Player collision work with tiles and word bound but do not work with other player and I don't understand why... Someone can help me please ?
×
×
  • Create New...