Michał Lipa

Members
  • Content Count

    8
  • Joined

  • Last visited

About Michał Lipa

  • Rank
    Newbie

Recent Profile Visitors

745 profile views
  1. Thanks, you were right about this code to delete. Now it's working smooth, but miniMap.clear() seems to work too good, because it clear whole map so often that I don't see any map during gameplay. How I can show on map only points from current update loop? This clear() delete whole miniMap.
  2. Im creating a minimap in my online game. I made a BitMapData in create(): miniMap = game.add.bitmapData(game.width/3, game.height/3); miniMap.addToWorld(-1000, -1000); drawnObject = game.add.sprite(270, game.height - 150, miniMap); drawnObject.anchor.setTo(0.5, 0.5); drawnObject.fixedToCamera = true; So minimap is created and now i update online players position on minimap: for now players position are random numbers onlinePlayers.forEach(function(p) { this.miniMap.ctx.beginPath(); this.miniMap.ctx.rect(self.getRandomNumer(100, 200), self.getRandomNumer(100, 200), 5, 5); this.miniMap.ctx.fillStyle = '#000'; this.miniMap.ctx.fill(); }); // miniMap.clear(0, 0, 250, 250); drawnObject = game.add.sprite(270, game.height - 150, miniMap); drawnObject.anchor.setTo(0.5, 0.5); drawnObject.fixedToCamera = true; So that is working but it drops down a fps after some time. I want to clear canvas every time and show only few dots (1 per player). minimap.clear() is deleting my minimap every frame of game. How I supposte to clear this minimap from players old positions and how to make it optimalised (without fps drop down).
  3. How I can add custom parameter of element of group. I need set that parameter during element creation. That will be string. My group: items = game.add.group(); items.enableBody = true; items.physicsBodyType = Phaser.Physics.ARCADE; creation of a new element: //Can I add custom parameter over here? I mean during creation items.create(new.x, new.y, 'texture'); Is there any option to set custom parameter during element creation? Right now I have elements with x, y, texture but I want one more paremater with my custom string.
  4. I'm creating a simple multiplayer game. I have got problem with rotating other players objects, if there are using arcade physics. Rotation works well without arcade physics, but I need to make work collisions and rotation so don't know how to handle that. //Online player object this.tank = game.add.sprite(x, y, 'tank'); game.physics.enable(this.tank, Phaser.Physics.ARCADE); //Changing rotation - updating all players rotation in loop player.tank.rotation = p.tankRotation; Why this doesn't work? I also tried with: player.tank.rotation = p.tankRotation; player.tank.body.rotation = p.tankRotation; player.tank.angle = p.tankRotation; player.tank.body.angle = p.tankRotation;
  5. I tried using socket 'disconnect' event but the problem is that I don't know how to identify user who already disconnected. client.on('joinGame', function(player){ console.log(player.id + ' joined the game'); connectCounter++; }); client.on('disconnect', function() { connectCounter--; //How to get disconnected player id? console.log('player disconnected -- closed socket'); });
  6. Do you have idea how to check if user closed game? I'm creating a multiplayer game and I need to trigger socket when user left game. I tried with these code in create(): window.onbeforeunload = function(e) { socket.emit('leaveGame', playerName); }; but these seems not to work
  7. How to make container/box for text like this on screen. (example: brutal.io) I mean what I supposted to use? graphics, pixi or what? Can someone post some example?
  8. I started working on game, which I would like to publish on Android and ios market. How I can set resolution or scale game to most popular devices? I found on google that the most popular resolution is (480, 320) var game = new Phaser.Game(480, 320, Phaser.CANVAS); I test my game (sample asstes) on Asus Zenphone GO (resolution: 720 x 1280 pixels) and this is how it looks (white space on top and sides). How developers scale their games to fit all phones?