Socket.io + Crafty

时间:2013-07-29 19:07:47

标签: javascript html frameworks socket.io game-engine

我正在尝试编写mmorpg游戏,我想用Crafty和Socket.io来做这件事,但是当我尝试连接时我有问题..

一切都适用于选定的时刻,当我尝试使用Crafty 时出现问题:/

    <!DOCTYPE html>
<html>
<head>
  <script src="crafty.js"></script> 
  <script src="gra.js"></script>
  <script src="/socket.io/socket.io.js"></script>
<script type="text/javascript">



 window.onload = function() {
                    var socket = io.connect('http://localhost:3250');

                    socket.on('connect', function() {           
                        panel.innerHTML = 'HELLOOO';            

                    });  //  <---- "THIS MOMENT" So far is all good

                Crafty.init(800, 800);
                Crafty.background('rgb(249, 223, 125)');

                }

</script>
</head>
<body>
    <div id="panel"></div>

</body>
</html>

服务器代码如果有这个帮助...

var app = require('http').createServer(handler)
,fs = require('fs')
,io = require('socket.io').listen(app)

app.listen(3250);

function handler(req, res) {
    fs.readFile('./lolo.html', function(err, data) {
        res.writeHead(200);
        res.end(data);
    });
}

io.sockets.on('connection', function(socket) {
   console.log("TEST");
});

修改

这是解决方案:D socket.io and differents folders --- solution found

0 个答案:

没有答案