Jump to content

Search the Community

Showing results for tags 'focuss'.

  • 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 started playing with phaser, some time ago. But now i wanted to try something new, something like Websocket + phaser. And i stuck :/ So, i want to make multiplayer "Game" but i stuck, i cannot happen that game will be still working in background. It should be working that i m logging at 1st tab and sprite is apearing, than i m logging at 2nd tab and on first another sprite is apearing but on different position. So at the end, at the 1st tab will be 3 sprites, or more, depends how many tabs you will open. Sry for my bad engladno :/ I hope you understood something. My code: Client: var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); var player; var cursors; function preload() { game.load.image('med1','client/assets/Unit/medievalUnit_01.png'); } function create() { game.stage.disableVisibilityChange = true; game.physics.startSystem(Phaser.Physics.ARCADE); cursors = game.input.keyboard.createCursorKeys(); game.input.mouse.capture = true; ws.send('NewPlayerJoined',nick); player = game.add.sprite(0,0,'med1'); player.nickname = nick; game.physics.enable(player, Phaser.Physics.ARCADE); ws.onmessage = function(data){ game.add.sprite(Math.floor((Math.random() * 100) + 1),Math.floor((Math.random() * 200) + 1),'med1'); console.log("NewPpl"); }; } function update() { if (cursors.left.isDown) { player.body.velocity.x = -100; }else if (cursors.right.isDown) { player.body.velocity.x = 100; }else{ player.body.velocity.x = 0; } if (cursors.up.isDown) { player.body.velocity.y = -100; }else if (cursors.down.isDown) { player.body.velocity.y = +100; }else{ player.body.velocity.y = 0; } } SERVER: const express = require('express'); const http = require('http'); const url = require('url'); const WebSocket = require('ws'); const app = express(); var players = {}; __dirname = 'E:/WebstormProjects/TestWorkingServer'; app.get('/',function(req, res) { res.sendFile(__dirname + '/client/index.html'); }); app.use('/client',express.static(__dirname + '/client')); const server = http.createServer(app); const wss = new WebSocket.Server({ server }); wss.on('connection', function connection(ws) { console.log("New Connection"); ws.on("message",function incoming(data) { ws.send("sumf"); }); }); server.listen(2000, function listening() { console.log('Listening on %d', server.address().port); });
×
×
  • Create New...