issue #1530: Updated MoonWarriors.

This commit is contained in:
James Chen 2012-11-16 14:13:06 +08:00
parent 7557a78e05
commit c2d8d118bf
10 changed files with 39 additions and 71 deletions

View File

@ -35,7 +35,7 @@ var Enemy = cc.Sprite.extend({
this._hurtColorLife--;
}
if (this._hurtColorLife == 1) {
this.setColor( cc.WHITE );
this.setColor( cc.c3b(255,255,255) );
}
}
},
@ -61,7 +61,7 @@ var Enemy = cc.Sprite.extend({
hurt:function () {
this._hurtColorLife = 2;
this.HP--;
this.setColor( cc.RED );
this.setColor( cc.c3b(255,0,0) );
},
collideRect:function(){
var a = this.getContentSize();

View File

@ -30,7 +30,6 @@ var GameLayer = cc.Layer.extend({
},
init:function () {
var bRet = false;
cc.log("GameLayer init");
if (this._super()) {
// reset global values
@ -65,7 +64,7 @@ var GameLayer = cc.Layer.extend({
// ship Life count
this._lbLife = cc.LabelTTF.create("0", "Arial", 20);
this._lbLife.setPosition(60, 463);
this._lbLife.setColor(cc.RED);
this._lbLife.setColor(cc.c3b(255,0,0));
this.addChild(this._lbLife, 1000);
// ship
@ -74,7 +73,7 @@ var GameLayer = cc.Layer.extend({
// accept touch now!
var t = cc.config.deviceType;
var t = cc.config.platform;
if( t == 'browser' ) {
this.setMouseEnabled(true);
this.setKeyboardEnabled(true);
@ -143,7 +142,7 @@ var GameLayer = cc.Layer.extend({
this.updateUI();
}
if( cc.config.deviceType == 'browser' )
if( cc.config.platform == 'browser' )
cc.$("#cou").innerHTML = "Ship:" + 1 + ", Enemy: " + MW.CONTAINER.ENEMIES.length + ", Bullet:" + MW.CONTAINER.ENEMY_BULLETS.length + "," + MW.CONTAINER.PLAYER_BULLETS.length + " all:" + this.getChildren().length;
},
checkIsCollide:function () {
@ -223,7 +222,7 @@ var GameLayer = cc.Layer.extend({
if (this._tmpScore < MW.SCORE) {
this._tmpScore += 5;
}
this._lbLife.setString(MW.LIFE);
this._lbLife.setString(MW.LIFE + '');
this.lbScore.setString("Score: " + this._tmpScore);
},
collide:function (a, b) {

View File

@ -1,9 +1,9 @@
var dirImg = "";
var dirMusic = "";
var musicSuffix = ".mp3";
if( cc.config.deviceType == 'browser') {
dirImg = "res/";
dirMusic = "res/Music/";
if( cc.config.platform == 'browser' ) {
dirImg = "MoonWarriors/res/";
dirMusic = "MoonWarriors/res/Music/";
musicSuffix = "";
}
else if( cc.config.engine == 'cocos2d-x') {

View File

@ -56,7 +56,7 @@ var Ship = cc.Sprite.extend({
update:function (dt) {
// Keys are only enabled on the browser
if( cc.config.deviceType == 'browser' ) {
if( cc.config.platform == 'browser' ) {
var pos = this.getPosition();
if ((MW.KEYS[cc.KEY.w] || MW.KEYS[cc.KEY.up]) && pos.y <= winSize.height) {
pos.y += dt * this.speed;
@ -83,7 +83,7 @@ var Ship = cc.Sprite.extend({
this._hurtColorLife--;
}
if (this._hurtColorLife == 1) {
this.setColor(cc.WHITE);
this.setColor(cc.c3b(255,255,255));
}
}
},
@ -116,7 +116,7 @@ var Ship = cc.Sprite.extend({
if (this.canBeAttack) {
this._hurtColorLife = 2;
this.HP--;
this.setColor(cc.RED);
this.setColor(cc.c3b(255,0,0));
}
},
collideRect:function(){

View File

@ -31,14 +31,9 @@ var SysMenu = cc.Layer.extend({
var aboutSelected = cc.Sprite.create(s_menu, cc.rect(252, 33, 126, 33));
var aboutDisabled = cc.Sprite.create(s_menu, cc.rect(252, 33 * 2, 126, 33));
cc.log("SysMenu init");
var newGame = cc.MenuItemSprite.create(newGameNormal, newGameSelected, newGameDisabled, function () {
cc.log("newGame callback1");
this.onButtonEffect();
cc.log("newGame callback2");
flareEffect(this, this, this.onNewGame);
cc.log("newGame callback3");
}.bind(this));
var gameSettings = cc.MenuItemSprite.create(gameSettingsNormal, gameSettingsSelected, gameSettingsDisabled, this.onSettings, this);
var about = cc.MenuItemSprite.create(aboutNormal, aboutSelected, aboutDisabled, this.onAbout, this);
@ -66,14 +61,10 @@ var SysMenu = cc.Layer.extend({
return bRet;
},
onNewGame:function (pSender) {
cc.log("onNewGame 1");
var scene = cc.Scene.create();
scene.addChild(GameLayer.create());
cc.log("onNewGame 2");
scene.addChild(GameControlMenu.create());
cc.log("onNewGame 3");
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2, scene));
cc.log("onNewGame 4");
},
onSettings:function (pSender) {
this.onButtonEffect();

View File

@ -2,11 +2,7 @@
// Javascript Bindigns helper file
//
cc.g = cc.g || cc.p;
cc.log = cc.log || log;
// DO NOT ALTER THE ORDER
require('js/helper/jsb_constants_cocos2d.js');
// require('jsb_constants_chipmunk.js');
require('js/helper/jsb_constants_gl.js');
require('js/helper/jsb_constants_cocosbuilder.js');

View File

@ -68,12 +68,25 @@ cc._reuse_p = [
{x:0, y:0},
{x:0, y:0}
];
cc._reuse_p_index = 0;
cc._reuse_size = {width:0, height:0};
cc._reuse_rect = {x:0, y:0, width:0, height:0};
cc._reuse_color3b = {r:255, g:255, b:255 };
cc._reuse_color4b = {r:255, g:255, b:255, a:255 };
cc._reuse_grid = {x:0, y:0};
//
// Point
//
cc.p = function( x, y )
{
return {x:x, y:y};
};
cc.g = cc.g || cc.p;
cc._reuse_grid = cc.g(0,0);
cc.log = cc.log || log;
//
// Color 3B
@ -87,9 +100,6 @@ cc._c3b = function (r, g, b) {
cc._reuse_color3b.b = b;
return cc._reuse_color3b;
};
// compatibility
cc.c3 = cc.c3b;
cc._c3 = cc._c3b;
//
// Color 4B
@ -108,7 +118,6 @@ cc._c4b = function (r, g, b, a) {
cc.c4 = cc.c4b;
cc._c4 = cc._c4b;
//
// Color 4F
//
@ -170,6 +179,17 @@ cc.sizeEqualToSize = function (size1, size2) {
cc.rect = function (x, y, w, h) {
return {x:x, y:y, width:w, height:h};
};
cc._rect = function(x,y,w,h)
{
cc._reuse_rect.x = x;
cc._reuse_rect.y = y;
cc._reuse_rect.width = w;
cc._reuse_rect.height = h;
return cc._reuse_rect;
};
cc.rectEqualToRect = function (rect1, rect2) {
return ( rect1.x==rect2.x && rect1.y==rect2.y && rect1.width==rect2.width && rect1.height==rect2.height);
};
cc._rect = function (x, y, w, h) {
cc._reuse_rect.x = x;
@ -345,6 +365,7 @@ cc.associateWithNative = function (jsobj, superclass_or_instance) {
// 1) Google "subclasses" borrowed from closure library
// This is the recommended way to do it
//
cc.inherits = function (childCtor, parentCtor) {
/** @constructor */
function tempCtor() {};
@ -389,6 +410,7 @@ cc.base = function (me, opt_methodName, var_args) {
'cc.base called from a method of one name ' +
'to a method of a different name');
}
};

View File

@ -203,26 +203,6 @@
RelativePath="..\..\..\scripting\javascript\bindings\cocos2d_specifics.hpp"
>
</File>
<File
RelativePath="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.cpp"
>
</File>
<File
RelativePath="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.h"
>
</File>
<File
RelativePath="..\..\..\scripting\javascript\bindings\js_bindings_config.h"
>
</File>
<File
RelativePath="..\..\..\scripting\javascript\bindings\js_manual_conversions.cpp"
>
</File>
<File
RelativePath="..\..\..\scripting\javascript\bindings\js_manual_conversions.h"
>
</File>
<File
RelativePath="..\..\..\scripting\javascript\bindings\ScriptingCore.cpp"
>

View File

@ -137,19 +137,14 @@ xcopy /Y /Q "$(SolutionDir)scripting\javascript\spidermonkey-win32\lib\*.*" "$(O
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.cpp" />
<ClCompile Include="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.cpp" />
<ClCompile Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.cpp" />
<ClCompile Include="..\..\..\scripting\javascript\bindings\js_manual_conversions.cpp" />
<ClCompile Include="..\..\..\scripting\javascript\bindings\ScriptingCore.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="..\Classes\AppDelegate.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.hpp" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.h" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.hpp" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\js_bindings_config.h" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\js_manual_conversions.h" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\ScriptingCore.h" />
<ClInclude Include="..\..\..\scripting\javascript\bindings\spidermonkey_specifics.h" />
<ClInclude Include="main.h" />

View File

@ -25,18 +25,12 @@
<ClCompile Include="..\Classes\AppDelegate.cpp">
<Filter>Classes</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scripting\javascript\bindings\js_manual_conversions.cpp">
<Filter>bindings</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scripting\javascript\bindings\ScriptingCore.cpp">
<Filter>bindings</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.cpp">
<Filter>bindings</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.cpp">
<Filter>bindings</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.cpp">
<Filter>bindings\generated</Filter>
</ClCompile>
@ -51,12 +45,6 @@
<ClInclude Include="..\Classes\AppDelegate.h">
<Filter>Classes</Filter>
</ClInclude>
<ClInclude Include="..\..\..\scripting\javascript\bindings\js_bindings_config.h">
<Filter>bindings</Filter>
</ClInclude>
<ClInclude Include="..\..\..\scripting\javascript\bindings\js_manual_conversions.h">
<Filter>bindings</Filter>
</ClInclude>
<ClInclude Include="..\..\..\scripting\javascript\bindings\ScriptingCore.h">
<Filter>bindings</Filter>
</ClInclude>
@ -66,9 +54,6 @@
<ClInclude Include="..\..\..\scripting\javascript\bindings\cocos2d_specifics.hpp">
<Filter>bindings</Filter>
</ClInclude>
<ClInclude Include="..\..\..\scripting\javascript\bindings\cocosjs_manual_conversions.h">
<Filter>bindings</Filter>
</ClInclude>
<ClInclude Include="..\..\..\scripting\javascript\bindings\generated\cocos2dx.hpp">
<Filter>bindings\generated</Filter>
</ClInclude>