i use canvasengine program html5 game. have implemented tiled map works far, static.
now want player have ability move around. thought: "ok, use canvasengine skew command". works:
canvas.scene.new ({ name: "tutorial", materials: { images: { dg_edging232: "/maps/tilesets/dg_edging232.gif" } }, ready: function(stage) { this.el = this.createelement(); var tiled = canvas.tiled.new (); tiled.load(this, this.el, "/maps/tutorial.json"); tiled.ready(function() { var tile_w = this.gettilewidth(), tile_h = this.gettileheight(), layer_object = this.getlayerobject(); stage.append(this.el); }); }, render: function(stage) { canvas.input.keydown(input.left); canvas.input.keydown(input.right); canvas.input.keydown(input.up); canvas.input.keydown(input.down); stage.refresh(); } });
now, i'd this:
canvas.input.keydown(input.left,this.el.x--);
but can't work syntax above.
never worked libarary, looks might want move keydown
calls have in render ready
, , on render, test whether key pressed , move sprite accordingly.
ready: function () { // ... ready code // it's not clear docs, appears need call // keydown each input register it, if you're passing no callbacks. // however, i'm guessing here. may not necessary. canvas.input.keydown(input.left); // ... , on each direction }, render: function () { // every frame test if key down, , update sprite accordingly if (canvas.input.ispressed(input.left)) this.el.x--; // ... , on each direction stage.refresh(); }
Comments
Post a Comment