2.0.0-beta.11 • Published 9 months ago
canvasengine v2.0.0-beta.11
Multiplayer
CanvasEngine implements a multiplayer game using NodeJS and Socket.io
- Install Node.js and NPM
Open the Shell :
npm install canvasengine
Create a. Js file in your project for the server
Here is an example of a client code :
<!DOCTYPE html>
<html>
<head>
<script src="canvasengine-X.Y.Z.all.min.js"></script>
<script src="extends/Socket.js"></script>
<script>
var Model = io.connect('http://127.0.0.1:8333');
var canvas = CE.defines("canvas").
ready(function() {
canvas.Scene.call("MyScene");
});
canvas.Scene.new({
name: "MyScene",
model: Model,
events: ["load"],
ready: function(stage) {
this.model.emit("start");
},
load: function(text) {
console.log(text);
}
});
</script>
</head>
<body>
<canvas id="canvas" width="675px" height="506px"></canvas>
</body>
</html>And server code :
var CE = require("canvasengine").listen(8333);
CE.Model.init("Main", ["start"], {
initialize: function() {
},
start: function() {
this.scene.emit("load", "Hello");
}
});- The client sends data to the server with the
emitmethodmodelproperty - The method defined in the array is performed (method name sent by the client)
- Conversely, data is sent to the scene with the
emitmethodsceneproperty Here, the
loadmethod is executed and defined in theeventsproperty
The methods are the same as Socket.io
2.0.0-beta.11
9 months ago
2.0.0-beta.10
9 months ago
2.0.0-beta.9
9 months ago
2.0.0-beta.8
10 months ago
2.0.0-beta.7
10 months ago
2.0.0-beta.6
10 months ago
2.0.0-beta.5
10 months ago
2.0.0-beta.4
10 months ago
2.0.0-beta.2
10 months ago
2.0.1-beta.2
11 months ago
2.0.0-beta.1
11 months ago
2.0.1-beta.1
11 months ago
2.0.0-beta.3
10 months ago
1.3.0
12 years ago
1.0.8
13 years ago