Puflo

Members
  • Content count

    16
  • Joined

  • Last visited

  1. Need cordova plugin

    I need to add google play games to my game, which cordova plugin would you recommend?
  2. Physics bug

    I can't get ship2 and ship3 to collide world bounds, what i'm doing wrong? They collide each other but only ship1 is colliding world bounds. ship1 = game.add.sprite(200, 300, 'ship'); game.physics.box2d.enable(ship1); ship1.body.setCircle(14); ship1.body.setCollisionCategory(1); ship2 = game.add.sprite(200, 200, 'ship'); game.physics.box2d.enable(ship2); ship2.body.setCircle(14); ship2.body.setCollisionCategory(2); ship2.body.setCollisionMask(3); ship3 = game.add.sprite(300, 200, 'ship'); game.physics.box2d.enable(ship3); ship3.body.setCircle(14); ship3.body.setCollisionCategory(2); ship3.body.setCollisionMask(3); game.physics.box2d.setBoundsToWorld(true, true, true, true, 1, 3); // or 2,3 Edit: I made a hotfix for this, but i'd like to know why is the example above isn't working. game.physics.box2d.setBoundsToWorld(true, true, true, true); for (var i in game.physics.box2d.walls){ game.physics.box2d.walls[i].setCollisionCategory(2); game.physics.box2d.walls[i].setCollisionMask(3); }
  3. Programming a ladder

    Not sure but i think you can do something like this: // update function var currentTile = map.getTile(mapLayer.getTileX(player.body.x), mapLayer.getTileY(player.body.y), mapLayer); if (currentTile.properties.isLadder && cursors.up.isDown){ player.body.velocity.y = -200; }
  4. Physics bug

    What exactly is 2 + 4 and why is collision mask 4 colliding with ship 2?
  5. Physics bug

    Box2D always calls contact callback twice. Here's an example: 185.50.68.103 Ship with collision category 2 (ship at left) calls contact callback once while ship with collision category 1 (default) calls it twice. I've been trying to fix this for weeks but couldn't find any solution in web, i really need you guys to help me. function create() { game.physics.startSystem(Phaser.Physics.BOX2D); game.stage.backgroundColor = '#2d2d2d'; // User-controlled ship ship1 = game.add.sprite(250, 300, 'ship'); game.physics.box2d.enable(ship1); ship1.body.setCircle(14); // Ship with collision category 2 (triggers contact callback only once, it shouldn't even trigger it) ship2 = game.add.sprite(200, 200, 'ship'); game.physics.box2d.enable(ship2); ship2.body.setCircle(14); ship2.body.setCollisionCategory(2); // Ship with collision category 1 *default, i guess* (triggers contact callback TWICE) ship3 = game.add.sprite(300, 200, 'ship'); game.physics.box2d.enable(ship3); ship3.body.setCircle(14); game.physics.box2d.setBoundsToWorld(true, true, true, true, false); ship1.body.setCategoryContactCallback(1, function(b1,b2,f1,f2,begin){ if (begin){ total += 1; hitText.text = 'Contact callback called '+total+' times'; console.log("CONTACT: ", b2) } }, this); cursors = game.input.keyboard.createCursorKeys(); game.add.text(5, 5, 'Use arrow keys to move.', { fill: '#ffffff', font: '14pt Arial' }); total = 0; hitText = game.add.text(5, 30, 'Contact callback called 0 times', { fill: '#ffffff', font: '14pt Arial' }); } function update() { if (cursors.left.isDown) { ship1.body.rotateLeft(300); } else if (cursors.right.isDown) { ship1.body.rotateRight(300); } else { ship1.body.setZeroRotation(); } if (cursors.up.isDown) { ship1.body.thrust(300); } else if (cursors.down.isDown) { ship1.body.reverse(300); } } function render() { game.debug.box2dWorld(); }
  6. Drawing a haxball-like ball in phaser

    Okay, i have a little question; how can i draw a colored circle with bitmapdata? Couldn't find anything in examples.
  7. Drawing a haxball-like ball in phaser

    What is the difference between bitmapText, text and graphics, bitmapData? Which one should i use for mobile games?
  8. I want to create a ball inside a circle line, is there any way to do this in Phaser?
  9. Game crashes when adding sprite to a group

    I've found another problem, sprite became invisible when you add it to a group. Game.js (create): game_name.entities = this.add.group(); Network.js is the same as the first post (except group.add, i only call it with sprite now.) Edit: It's because group was created in another state, i've fixed it.
  10. Game crashes with this error after adding a sprite to a group. I need to add a sprite to specific index of a group. var entity = game.add.sprite(x, y, (teamId == 1 ? "a" : (teamId == 2 ? "b" : "c"))+"_"+skinId); entity.scale.set(teamId==0?1:0.5); entity.anchor.set(0.5, 0.5); game.physics.box2d.enable(entity); entity.body.angle = angle; if (teamId != 0){ entity.body.setCollisionCategory(teamId == 1 ? 2 : 3); } if (name){ entity.nametag = game.add.text(entity.x, entity.y - 35, name, { font: "16px Ubuntu", fontWeight:'bold', fill: "#ffffff", stroke:'#000000', strokeThickness:2.5, wordWrapWidth: entity.width, align: "center"}); entity.nametag.anchor.set(0.5); } entity.data.entityId = entityId; entity.data.teamId = teamId; if (entityId == user.entityId){ game.camera.follow(entity); if (teamId == 2){ entity.body.setCategoryContactCallback(2, game.state.getCurrentState().onPlayerHit); } } game_name.entities.add(entity, false, entityId); I even tried using addAt, it doesn't work either. Is this a bug?
  11. Box2D Bug?

    I'm having the same problem, been working on a solution but i couldn't fix it. It happens when you destroy a sprite with box2d body, especially when you are switching browser tabs. (Sorry for bumping an old thread)