// This sample shows an image that will move to the right when clicked enchant(); window.onload = function () { var game = new Game(320, 320); game.preload('chara0.gif'); game.onload = function() { var scene = new Scene(); var sprite = new Sprite(32, 32); sprite.image = game.assets['chara0.gif']; scene.addChild(sprite); sprite.addEventListener('touchstart', function() { sprite.x += 1; }); game.pushScene(scene); }; game.start(); };
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Game.js</title> <script src="js/enchant.js"></script> <script src="js/main.js"></script> </head> <body> </body> </html>
enchant(); window.onload = function(){ //Setting up the game var game = new Core(500, 700); //preloading the res game.preload('res/ghost.png'); // setting the fps view and onload game.fps = 20; game.scale = 0; game.onload = function(){ //setting up the scene var mainFrame = new Scene(); mainFrame.backgroundColor = 'blue'; //loading image from preload into mainframe var playerOne = new Sprite(32, 32); playerOne.image = game.assets['res/ghost.png']; //finallying wellcome to the game ghost. mainFrame.addChild(playerOne); //moving ghost aka playerOne around. playerOne.addEventListener('touchstart', function(){ if(LEFT_BUTTON_DOWN){ playerOne.x +=0.1; } }); //game.pushScene(mainFrame); game.rootScene.addChild(mainFrame); } game.start(); };
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)