finspin

Members
  • Content Count

    8
  • Joined

  • Last visited

About finspin

  • Rank
    Newbie

Recent Profile Visitors

541 profile views
  1. In the end I got the PhysicsEditor
  2. I only need to export image map(?) in JSON format so that I can load physics data in Phaser. Thanks for the recommendation but RUBE seems to be even more expensive than PhysicsEditor.
  3. Is there any alternative to https://www.codeandweb.com/physicseditor? I'm just learning Phaser and can't spend 20 EUR on the physics editor at this point (I tried it a month ago and the free trial has expired).
  4. I have 2 bouncing balls which are bouncing off world borders and also off each other. The balls do maintain their speed when bouncing off the world borders but they lose their speed when bouncing off each other. I'd like them to maintain their speed after they collide with each other. I realise this is quite against the physics but is this doable? Here it the game implemented with p2 physics http://finspin.github.io/bubble-game/version-2/ and the code below. And here is the same game implemented with arcade engine where balls are bouncing without losing the speed http://finspin.github.io/bubble-game/version-1/. I switched from the arcade engine to p2 after I learned arcade can't handle collision of circular objects. var game = new Phaser.Game(480, 640, Phaser.AUTO, 'Bubble Game', { preload: preload, create: create, update: update, render: render});var b1, b2, bubble1, bubble2;function preload() {}function create() { game.stage.backgroundColor = "#000"; game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.setImpactEvents(true); var bubbleCollisionGroup = game.physics.p2.createCollisionGroup(); game.physics.p2.updateBoundsCollisionGroup(); b1 = game.add.graphics(); b1.beginFill(0xFF0000, 1); b1.drawCircle(0, 0, 50); bubble1 = game.add.sprite(game.world.width - 380, game.world.height - 50); bubble1.addChild(b1); bubble1.anchor.setTo(0.5, 0.5); b2 = game.add.graphics(); b2.beginFill(0xFFFFFF, 1); b2.drawCircle(0, 0, 50); bubble2 = game.add.sprite(game.world.width - 245, game.world.height - 50); bubble2.addChild(b2); bubble2.anchor.setTo(0.5, 0.5); bubbles = game.add.group(); bubbles.add(bubble1); bubbles.add(bubble2); game.physics.p2.enable(bubbles); bubbles.forEach(function (bubble) { bubble.body.setCircle(50); bubble.body.setCollisionGroup(bubbleCollisionGroup); bubble.body.collides([bubbleCollisionGroup, bubbleCollisionGroup]); }); var bubbleMaterial = game.physics.p2.createMaterial('bubbleMaterial'); var worldMaterial = game.physics.p2.createMaterial('worldMaterial'); bubble1.body.setMaterial(bubbleMaterial); bubble2.body.setMaterial(bubbleMaterial); game.physics.p2.setWorldMaterial(worldMaterial, true, true, true, true); var contactMaterial = game.physics.p2.createContactMaterial(bubbleMaterial, worldMaterial); contactMaterial.friction = 0; contactMaterial.restitution = 1.0; bubble1.body.damping = 0; bubble1.body.velocity.x = 200; bubble1.body.velocity.y = -200; bubble2.body.damping = 0; bubble2.body.velocity.x = -100; bubble2.body.velocity.y = 250;}function update() {}function render() {}
  5. How could I make ball bouncing off the world borders constantly? I tried to play around with contactMaterial properties but nothing seems to do the job. The ball will slowly lose its velocity. I'd like it to bounce constantly with constant velocity. var game = new Phaser.Game(480, 640, Phaser.AUTO, 'Bubble Game', { preload: preload, create: create, update: update, render: render});var bubble1;function preload() { game.load.image('bubble1', 'assets/bubble1.png');// game.load.image('bubble2', 'assets/bubble2.png');// game.load.image('bubble3', 'assets/bubble3.png');}function create() { game.stage.backgroundColor = "#000"; game.physics.startSystem(Phaser.Physics.P2JS); bubble1 = game.add.sprite(game.world.centerX, game.world.centerY, 'bubble1'); game.physics.p2.enable(bubble1); bubble1.body.setCircle(50); var bubbleMaterial = game.physics.p2.createMaterial('bubbleMaterial', bubble1.body); var worldMaterial = game.physics.p2.createMaterial('worldMaterial'); game.physics.p2.setWorldMaterial(worldMaterial, true, true, true, true); var contactMaterial = game.physics.p2.createContactMaterial(bubbleMaterial, worldMaterial); contactMaterial.friction = 0; contactMaterial.restitution = 1.0; contactMaterial.stiffness = 0; contactMaterial.relaxation = 0; contactMaterial.frictionStiffness = 0; contactMaterial.frictionRelaxation = 0; contactMaterial.surfaceVelocity = 0; bubble1.body.velocity.x = 200; bubble1.body.velocity.y = 200;}function update() {}function render() {}
  6. Yes, I think my problem is that the bubbles are in fact not rounded but they are seen as squares. I have uploaded my example here http://finspin.github.io/bubble-game/. Could you please point me to the right direction how to achieve collision of rounded objects?
  7. Hi, my first game and first post on this forum. I'm looking for help with collisions, having difficult time to understand why they don't work as expected. There are 3 bouncing balls but sometimes they collide "too early", meaning they bounce off each other before they actually touch. In some cases they collide as expected. Could you show me what I'm doing wrong here? var game = new Phaser.Game(480, 640, Phaser.AUTO, '', { preload: preload, create: create, update: update});var bubble1, bubble2, bubble3, bubbles;function preload() { game.load.image('bubble1', 'assets/bubble1.png'); game.load.image('bubble2', 'assets/bubble2.png'); game.load.image('bubble3', 'assets/bubble3.png');}function create() { game.stage.backgroundColor = '#ccc'; game.physics.startSystem(Phaser.Physics.ARCADE); bubble1 = game.add.sprite(50, game.world.height - 50, 'bubble1'); bubble2 = game.add.sprite(200, game.world.height - 50, 'bubble2'); bubble3 = game.add.sprite(350, game.world.height - 50, 'bubble3'); bubbles = game.add.group(); bubbles.add(bubble1); bubbles.add(bubble2); bubbles.add(bubble3); bubbles.enableBody = true; bubbles.setAll('anchor.x', 0.5); bubbles.setAll('anchor.y', 0.5); bubbles.forEach(function (bubble) { game.physics.arcade.enable(bubble); bubble.body.collideWorldBounds = true; bubble.body.bounce.set(1); }); bubble1.body.velocity.setTo(200, 200); bubble2.body.velocity.setTo(250, 250); bubble3.body.velocity.setTo(100, 200);}function update() { game.physics.arcade.collide(bubbles, bubbles);}