Skip to content
Browse files

cocos2d 'hello world' template added

  • Loading branch information...
1 parent 051d923 commit c092817815ff83c65d356188a7312191958af542 @luizgustavolino luizgustavolino committed Nov 17, 2012
Showing with 864 additions and 0 deletions.
  1. +28 −0 Classes/AppDelegate.js
  2. +726 −0 Lib/Cocos2d-html5-canvasmenu-min.js
  3. +32 −0 PirateRiot.js
  4. +52 −0 cocos2d.js
  5. +26 −0 index.html
View
28 Classes/AppDelegate.js
@@ -0,0 +1,28 @@
+var cc = cc = cc || {};
+
+cc.AppDelegate = cc.Application.extend({
+ ctor:function () {
+ this._super();
+ },
+
+ initInstance:function () {
+ return true;
+ },
+
+ applicationDidFinishLaunching:function () {
+ var director = cc.Director.sharedDirector();
+ director.setDisplayFPS(false);
+ director.setAnimationInterval(1.0 / 60);
+ var scene = PirateRiot.scene();
+ director.runWithScene(scene);
+ return true;
+ },
+
+ applicationDidEnterBackground:function () {
+ cc.Director.sharedDirector().pause();
+ },
+
+ applicationWillEnterForeground:function () {
+ cc.Director.sharedDirector().resume();
+ }
+});
View
726 Lib/Cocos2d-html5-canvasmenu-min.js
726 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
32 PirateRiot.js
@@ -0,0 +1,32 @@
+
+var PirateRiot = cc.Layer.extend({
+ isMouseDown:false,
+ helloLabel:null,
+
+ init:function () {
+
+ this._super();
+ var size = cc.Director.sharedDirector().getWinSize();
+ this.helloLabel = cc.LabelTTF.create("Pirate Riot, Arrr!", "Arial", 28);
+ this.helloLabel.setPosition(cc.ccp(size.width / 2, size.height - 40));
+ this.addChild(this.helloLabel);
+ return true;
+ }
+
+});
+
+PirateRiot.scene = function () {
+ var scene = cc.Scene.create();
+ var layer = this.node();
+ scene.addChild(layer);
+ return scene;
+};
+
+PirateRiot.node = function () {
+ var ret = new PirateRiot();
+ if (ret && ret.init()) return ret;
+ return null;
+};
+
+
+
View
52 cocos2d.js
@@ -0,0 +1,52 @@
+
+var cc = cc = cc || {};
+cc.Dir = './';
+cc.loadQue = [];
+cc.COCOS2D_DEBUG = 2;
+cc._DEBUG = 1;
+cc._IS_RETINA_DISPLAY_SUPPORTED = 0;
+
+//html5 selector method
+cc.$ = function (x) {
+ return document.querySelector(x);
+};
+cc.$new = function (x) {
+ return document.createElement(x);
+};
+
+cc.loadjs = function (filename) {
+
+ var script = cc.$new('script');
+ script.src = cc.Dir + filename;
+ script.order = cc.loadQue.length;
+ cc.loadQue.push(script);
+
+ script.onload = function () {
+
+ if (this.order + 1 < cc.loadQue.length) {
+ cc.$('head').appendChild(cc.loadQue[this.order + 1]);
+ }
+ else {
+ cc.setup("gameCanvas");
+ cc.AudioManager.sharedEngine().init("mp3");
+ cc.Loader.shareLoader().onloading = function () {
+ cc.LoaderScene.shareLoaderScene().draw();
+ };
+ cc.Loader.shareLoader().onload = function () {
+ cc.AppController.shareAppController().didFinishLaunchingWithOptions();
+ };
+
+ cc.Loader.shareLoader().preload([
+ //{type:"image", src:"Resources/HelloWorld.png"}
+ ]);
+ }
+ };
+
+ if (script.order === 0){
+ cc.$('head').appendChild(script);
+ }
+};
+
+cc.loadjs('Lib/Cocos2d-html5-canvasmenu-min.js');
+cc.loadjs('Classes/AppDelegate.js');
+cc.loadjs('PirateRiot.js');
View
26 index.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <!--
+
+ Pirate Riot,
+ developed by tsubasa soft. on the GithubGameOff, 2012.
+
+ Code: @luizGustavoLino
+ Assets: @lumiMae
+
+ Thank you for playing.
+ Ah! Visit our blog at tsubasa.com.br.
+
+ -->
+ <meta charset="utf-8">
+ <title>Pirate Riot</title>
+ <link rel="icon" type="image/GIF" href="http://tsubasa.com.br/blog/wp-content/themes/pixelpower/favicon.gif"/>
+ </head>
+ <body style="padding:0; margin: 0; background: #333;">
+ <div style="text-align: center; font-size: 0">
+ <canvas id="gameCanvas" width="640" height="480" style="margin: 10px; background: #000;"></canvas>
+ </div>
+ </body>
+</html>
+<script src="cocos2d.js"></script>

0 comments on commit c092817

Please sign in to comment.
Something went wrong with that request. Please try again.