Jump to content

Any books or tutorials about phaser + socket.io ??


danmoople
 Share

Recommended Posts

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

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

  • 4 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...