danmoople Posted February 3, 2017 Share Posted February 3, 2017 Hello everybody! I can create single player games with phaser and now I want to start making multiplayer games using socket.io + node.js So unfortunately I haven't found any tutorials about how to create games on phaser with phaser. I have never had projects with serverpart(so I have no experience in it) So that's all I could understand and write myself :[ SERVER PART var express = require('express'); var app = express(); var serv = require('http').Server(app); var counter = 0; app.get('/', function(req, res) { res.sendFile(__dirname + '/client/index.html'); }); app.use('/client', express.static('/client')); serv.listen(2000); console.log('server started'); var io = require('socket.io')(serv); io.sockets.on('connection', function(socket) { counter++; console.log('connection #' + counter); }); Client <script> var socket = io(); var sendInfo = function() { socket.emit('objAppear'); } </script> <button id="btn" onclick="sendInfo();">Appear</button> Of course that's the simplest thing to create using node + socket.io So now I want to create multiplayer in games I've already created. But how?!?! I can't find any tutorials. Can you please help me. Server part is too hard for me Link to comment Share on other sites More sharing options...
PhasedEvolution Posted February 3, 2017 Share Posted February 3, 2017 Have you seen the tanks example? http://ezelia.com/2014/tutorial-creating-basic-multiplayer-game-phaser-eureca-io Preety good I think The_dude8080 1 Link to comment Share on other sites More sharing options...
Arcanorum Posted February 3, 2017 Share Posted February 3, 2017 You are not alone. Socket.io does have poor documentation and lacks many good tutorials/explanations. Which is a shame, as it is nice to use when you eventually know how it works... What are you wanting to use for the gameplay logic on the server? Phaser can be made to run on the server, but it is not elegant. http://www.html5gamedevs.com/topic/7393-running-phaser-on-nodejs-how-i-did-it-and-why-you-shouldnt-do-it/ Also, I would recommend not sending files from a Node server unless you have to, as it is not what Node is designed for. Use a proper CDN. Upload the client files to your web host, so whenever a user goes to the page the game is on, they download the files from there, instead of your Node server sending them. Link to comment Share on other sites More sharing options...
danmoople Posted February 4, 2017 Author Share Posted February 4, 2017 9 hours ago, PhasedEvolution said: Have you seen the tanks example? http://ezelia.com/2014/tutorial-creating-basic-multiplayer-game-phaser-eureca-io Preety good I think Yeah I have but it uses "Eureca.io" but not Socket.io Link to comment Share on other sites More sharing options...
PBMCube Posted June 9, 2017 Share Posted June 9, 2017 I recommend the Ultimate Phaser Library http://leanpub.com/b/ultimatephaserlibrary It cover 2-player and MMoG. Link to comment Share on other sites More sharing options...
Recommended Posts