mirror of https://github.com/axmolengine/axmol.git
issue #1469: Removed some unused resources.
This commit is contained in:
parent
36d8e86879
commit
122a748029
|
@ -1,69 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2010-2012 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
// boot code needed for cocos2d-html5
|
|
||||||
// Not needed by cocos2d + JS bindings
|
|
||||||
|
|
||||||
var MW = MW || {};
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
var d = document;
|
|
||||||
var c = {
|
|
||||||
menuType:'canvas', //whether to use canvas mode menu or dom menu
|
|
||||||
COCOS2D_DEBUG:2, //0 to turn debug off, 1 for basic debug, and 2 for full debug
|
|
||||||
showFPS:true,
|
|
||||||
frameRate:60,
|
|
||||||
tag:'gameCanvas', //the dom element to run cocos2d on
|
|
||||||
engineDir:'libs/cocos2d/',
|
|
||||||
appFiles:[
|
|
||||||
'MoonWarriors/src/Resource.js',
|
|
||||||
'MoonWarriors/src/config/GameConfig.js',
|
|
||||||
'MoonWarriors/src/config/EnemyType.js',
|
|
||||||
'MoonWarriors/src/config/Level.js',
|
|
||||||
'MoonWarriors/src/Effect.js',
|
|
||||||
'MoonWarriors/src/Bullet.js',
|
|
||||||
'MoonWarriors/src/Enemy.js',
|
|
||||||
'MoonWarriors/src/Explosion.js',
|
|
||||||
'MoonWarriors/src/Ship.js',
|
|
||||||
'MoonWarriors/src/LevelManager.js',
|
|
||||||
'MoonWarriors/src/GameController.js',
|
|
||||||
'MoonWarriors/src/GameControlMenu.js',
|
|
||||||
'MoonWarriors/src/GameLayer.js',
|
|
||||||
'MoonWarriors/src/GameOver.js',
|
|
||||||
'MoonWarriors/src/AboutLayer.js',
|
|
||||||
'MoonWarriors/src/SettingsLayer.js',
|
|
||||||
'MoonWarriors/src/SysMenu.js'
|
|
||||||
]
|
|
||||||
};
|
|
||||||
window.addEventListener('DOMContentLoaded', function () {
|
|
||||||
//first load engine file if specified
|
|
||||||
var s = d.createElement('script');
|
|
||||||
s.src = c.engineDir + 'platform/jsloader.js';
|
|
||||||
d.body.appendChild(s);
|
|
||||||
s.c = c;
|
|
||||||
s.id = 'cocos2d-html5';
|
|
||||||
//else if single file specified, load singlefile
|
|
||||||
});
|
|
||||||
})();
|
|
|
@ -1,69 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2010-2012 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
// boot code needed for cocos2d + JS bindings.
|
|
||||||
// Not needed by cocos2d-html5
|
|
||||||
|
|
||||||
require("js/jsb_constants.js");
|
|
||||||
|
|
||||||
var MW = MW || {};
|
|
||||||
|
|
||||||
var appFiles = [
|
|
||||||
'MoonWarriors/src/Resource.js',
|
|
||||||
'MoonWarriors/src/config/GameConfig.js',
|
|
||||||
'MoonWarriors/src/config/EnemyType.js',
|
|
||||||
'MoonWarriors/src/config/Level.js',
|
|
||||||
'MoonWarriors/src/Effect.js',
|
|
||||||
'MoonWarriors/src/Bullet.js',
|
|
||||||
'MoonWarriors/src/Enemy.js',
|
|
||||||
'MoonWarriors/src/Explosion.js',
|
|
||||||
'MoonWarriors/src/Ship.js',
|
|
||||||
'MoonWarriors/src/LevelManager.js',
|
|
||||||
'MoonWarriors/src/GameControlMenu.js',
|
|
||||||
'MoonWarriors/src/GameLayer.js',
|
|
||||||
'MoonWarriors/src/GameOver.js',
|
|
||||||
'MoonWarriors/src/AboutLayer.js',
|
|
||||||
'MoonWarriors/src/SettingsLayer.js',
|
|
||||||
'MoonWarriors/src/SysMenu.js'
|
|
||||||
];
|
|
||||||
|
|
||||||
cc.dumpConfig();
|
|
||||||
|
|
||||||
for( var i=0; i < appFiles.length; i++) {
|
|
||||||
require( appFiles[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
var director = cc.Director.getInstance();
|
|
||||||
director.setDisplayStats(true);
|
|
||||||
|
|
||||||
// set FPS. the default value is 1.0/60 if you don't call this
|
|
||||||
director.setAnimationInterval(1.0 / 60);
|
|
||||||
|
|
||||||
// create a scene. it's an autorelease object
|
|
||||||
var mainScene = SysMenu.scene();
|
|
||||||
|
|
||||||
// run
|
|
||||||
director.runWithScene(mainScene);
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
59362b16ba4da187e064648be4d0bcb1c09b504d
|
|
|
@ -1 +0,0 @@
|
||||||
c0488f23a6a785893f4845b7fadc59ed892ceedc
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
46f10a6bf5c63f03ddf8566f392aa7a8f258d7e8
|
|
|
@ -1 +0,0 @@
|
||||||
97bca7d49fb6ec5c330f6ab6f5f49d335601a669
|
|
|
@ -1 +0,0 @@
|
||||||
ca7905a1a07e2be3e02fbf329772c2c361400af7
|
|
|
@ -1,47 +0,0 @@
|
||||||
var AboutLayer = cc.Layer.extend({
|
|
||||||
ctor:function () {
|
|
||||||
cc.associateWithNative( this, cc.Layer );
|
|
||||||
},
|
|
||||||
init:function () {
|
|
||||||
var bRet = false;
|
|
||||||
if (this._super()) {
|
|
||||||
var sp = cc.Sprite.create(s_loading);
|
|
||||||
sp.setAnchorPoint(cc.p(0,0));
|
|
||||||
this.addChild(sp, 0, 1);
|
|
||||||
|
|
||||||
var cacheImage = cc.TextureCache.getInstance().addImage(s_menuTitle);
|
|
||||||
var title = cc.Sprite.createWithTexture(cacheImage, cc.rect(0, 36, 100, 34));
|
|
||||||
title.setPosition(cc.p(winSize.width / 2, winSize.height - 60));
|
|
||||||
this.addChild(title);
|
|
||||||
|
|
||||||
// There is a bug in LabelTTF native. Apparently it fails with some unicode chars.
|
|
||||||
// var about = cc.LabelTTF.create(" This showcase utilizes many features from Cocos2d-html5 engine, including: Parallax background, tilemap, actions, ease, frame animation, schedule, Labels, keyboard Dispatcher, Scene Transition. \n Art and audio is copyrighted by Enigmata Genus Revenge, you may not use any copyrigted material without permission. This showcase is licensed under GPL. \n \n Programmer: \n Shengxiang Chen (陈升想) \n Dingping Lv (吕定平) \n Effects animation: Hao Wu(吴昊)\n Quality Assurance: Sean Lin(林顺)", "Arial", 14, cc.size(winSize.width * 0.85, 100), cc.TEXT_ALIGNMENT_LEFT );
|
|
||||||
var about = cc.LabelTTF.create(" This showcase utilizes many features from Cocos2d-html5 engine, including: Parallax background, tilemap, actions, ease, frame animation, schedule, Labels, keyboard Dispatcher, Scene Transition. \n Art and audio is copyrighted by Enigmata Genus Revenge, you may not use any copyrigted material without permission. This showcase is licensed under GPL. \n\nProgrammer: \n Shengxiang Chen\n Dingping Lv \n Effects animation: Hao Wu\n Quality Assurance: Sean Lin", "Arial", 14, cc.size(winSize.width * 0.85, 320), cc.TEXT_ALIGNMENT_LEFT );
|
|
||||||
about.setPosition(cc.p(winSize.width / 2, winSize.height/2 -20) );
|
|
||||||
about.setAnchorPoint( cc.p(0.5, 0.5));
|
|
||||||
this.addChild(about);
|
|
||||||
|
|
||||||
var label = cc.LabelTTF.create("Go back", "Arial", 14);
|
|
||||||
var back = cc.MenuItemLabel.create(label, this, this.backCallback);
|
|
||||||
var menu = cc.Menu.create(back);
|
|
||||||
menu.setPosition(cc.p(winSize.width / 2, 40));
|
|
||||||
this.addChild(menu);
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
},
|
|
||||||
backCallback:function (pSender) {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
scene.addChild(SysMenu.create());
|
|
||||||
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2, scene));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
AboutLayer.create = function () {
|
|
||||||
var sg = new AboutLayer();
|
|
||||||
if (sg && sg.init()) {
|
|
||||||
return sg;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
|
@ -1,62 +0,0 @@
|
||||||
//bullet
|
|
||||||
var Bullet = cc.Sprite.extend({
|
|
||||||
active:true,
|
|
||||||
xVelocity:0,
|
|
||||||
yVelocity:200,
|
|
||||||
power:1,
|
|
||||||
HP:1,
|
|
||||||
moveType:null,
|
|
||||||
zOrder:3000,
|
|
||||||
attackMode:MW.ENEMY_MOVE_TYPE.NORMAL,
|
|
||||||
parentType:MW.BULLET_TYPE.PLAYER,
|
|
||||||
ctor:function (bulletSpeed, weaponType, attackMode) {
|
|
||||||
// needed for JS-Bindings compatibility
|
|
||||||
cc.associateWithNative( this, cc.Sprite );
|
|
||||||
|
|
||||||
this.yVelocity = -bulletSpeed;
|
|
||||||
this.attackMode = attackMode;
|
|
||||||
cc.SpriteFrameCache.getInstance().addSpriteFrames(s_bullet_plist);
|
|
||||||
this.initWithSpriteFrameName(weaponType);
|
|
||||||
this.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
||||||
/*var tmpAction;
|
|
||||||
switch (this.attackMode) {
|
|
||||||
case MW.ENEMY_MOVE_TYPE.NORMAL:
|
|
||||||
tmpAction = cc.MoveBy.create(2, cc.p(this.getPosition().x, 400));
|
|
||||||
break;
|
|
||||||
case MW.ENEMY_ATTACK_MODE.TSUIHIKIDAN:
|
|
||||||
tmpAction = cc.MoveTo.create(2, GameLayer.create()._ship.getPosition());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.runAction(tmpAction);*/
|
|
||||||
},
|
|
||||||
update:function (dt) {
|
|
||||||
var p = this.getPosition();
|
|
||||||
p.x -= this.xVelocity * dt;
|
|
||||||
p.y -= this.yVelocity * dt;
|
|
||||||
this.setPosition( p );
|
|
||||||
if (this.HP <= 0) {
|
|
||||||
this.active = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
destroy:function () {
|
|
||||||
var explode = cc.Sprite.create(s_hit);
|
|
||||||
explode.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
||||||
explode.setPosition(this.getPosition());
|
|
||||||
explode.setRotation(Math.random()*360);
|
|
||||||
explode.setScale(0.75);
|
|
||||||
this.getParent().addChild(explode,9999);
|
|
||||||
cc.ArrayRemoveObject(MW.CONTAINER.ENEMY_BULLETS,this);
|
|
||||||
cc.ArrayRemoveObject(MW.CONTAINER.PLAYER_BULLETS,this);
|
|
||||||
this.removeFromParentAndCleanup(true);
|
|
||||||
var removeExplode = cc.CallFunc.create(explode,explode.removeFromParentAndCleanup);
|
|
||||||
explode.runAction(cc.ScaleBy.create(0.3, 2,2));
|
|
||||||
explode.runAction(cc.Sequence.create(cc.FadeOut.create(0.3), removeExplode));
|
|
||||||
},
|
|
||||||
hurt:function () {
|
|
||||||
this.HP--;
|
|
||||||
},
|
|
||||||
collideRect:function(){
|
|
||||||
var p = this.getPosition();
|
|
||||||
return cc.rect(p.x - 3, p.y - 3, 6, 6);
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,78 +0,0 @@
|
||||||
var flareEffect = function (parent, target, callback) {
|
|
||||||
var flare = cc.Sprite.create(s_flare);
|
|
||||||
flare.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
||||||
parent.addChild(flare, 10);
|
|
||||||
flare.setOpacity(0);
|
|
||||||
flare.setPosition(cc.p(-30, 297));
|
|
||||||
flare.setRotation(-120);
|
|
||||||
flare.setScale(0.2);
|
|
||||||
|
|
||||||
var opacityAnim = cc.FadeTo.create(0.5, 255);
|
|
||||||
var opacDim = cc.FadeTo.create(1, 0);
|
|
||||||
var biggeAnim = cc.ScaleBy.create(0.7, 1.2, 1.2);
|
|
||||||
var biggerEase = cc.EaseSineOut.create(biggeAnim);
|
|
||||||
var moveAnim = cc.MoveBy.create(0.5, cc.p(328, 0));
|
|
||||||
var easeMove = cc.EaseSineOut.create(moveAnim);
|
|
||||||
var rotateAnim = cc.RotateBy.create(2.5, 90);
|
|
||||||
var rotateEase = cc.EaseExponentialOut.create(rotateAnim);
|
|
||||||
var bigger = cc.ScaleTo.create(0.5, 1);
|
|
||||||
|
|
||||||
var onComplete = cc.CallFunc.create(target, callback);
|
|
||||||
var killflare = cc.CallFunc.create(flare, function () {
|
|
||||||
this.getParent().removeChild(this,true);
|
|
||||||
});
|
|
||||||
flare.runAction(cc.Sequence.create(opacityAnim, biggerEase, opacDim, killflare, onComplete));
|
|
||||||
flare.runAction(easeMove);
|
|
||||||
flare.runAction(rotateEase);
|
|
||||||
flare.runAction(bigger);
|
|
||||||
};
|
|
||||||
|
|
||||||
var removeFromParent = function( sprite )
|
|
||||||
{
|
|
||||||
sprite.removeFromParentAndCleanup( true );
|
|
||||||
};
|
|
||||||
|
|
||||||
var spark = function (ccpoint, parent, scale, duration) {
|
|
||||||
scale = scale || 0.3;
|
|
||||||
duration = duration || 0.5;
|
|
||||||
|
|
||||||
var one = cc.Sprite.create(s_explode1);
|
|
||||||
var two = cc.Sprite.create(s_explode2);
|
|
||||||
var three = cc.Sprite.create(s_explode3);
|
|
||||||
|
|
||||||
one.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
||||||
two.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
||||||
three.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
||||||
|
|
||||||
one.setPosition(ccpoint);
|
|
||||||
two.setPosition(ccpoint);
|
|
||||||
three.setPosition(ccpoint);
|
|
||||||
|
|
||||||
//parent.addChild(one);
|
|
||||||
parent.addChild(two);
|
|
||||||
parent.addChild(three);
|
|
||||||
one.setScale(scale);
|
|
||||||
two.setScale(scale);
|
|
||||||
three.setScale(scale);
|
|
||||||
|
|
||||||
three.setRotation(Math.random() * 360);
|
|
||||||
|
|
||||||
var left = cc.RotateBy.create(duration, -45);
|
|
||||||
var right = cc.RotateBy.create(duration, 45);
|
|
||||||
var scaleBy = cc.ScaleBy.create(duration, 3, 3);
|
|
||||||
var fadeOut = cc.FadeOut.create(duration);
|
|
||||||
var remove = cc.CallFunc.create(this, removeFromParent );
|
|
||||||
var seq = cc.Sequence.create( fadeOut, remove );
|
|
||||||
|
|
||||||
one.runAction(left);
|
|
||||||
two.runAction(right);
|
|
||||||
|
|
||||||
one.runAction(scaleBy);
|
|
||||||
two.runAction(scaleBy.copy());
|
|
||||||
three.runAction(scaleBy.copy());
|
|
||||||
|
|
||||||
one.runAction(seq);
|
|
||||||
two.runAction(seq.copy() );
|
|
||||||
three.runAction(seq.copy());
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
var Enemy = cc.Sprite.extend({
|
|
||||||
eID:0,
|
|
||||||
active:true,
|
|
||||||
speed:200,
|
|
||||||
bulletSpeed:-200,
|
|
||||||
HP:15,
|
|
||||||
bulletPowerValue:1,
|
|
||||||
moveType:null,
|
|
||||||
scoreValue:200,
|
|
||||||
zOrder:1000,
|
|
||||||
delayTime:1 + 1.2 * Math.random(),
|
|
||||||
attackMode:MW.ENEMY_MOVE_TYPE.NORMAL,
|
|
||||||
_hurtColorLife:0,
|
|
||||||
ctor:function (arg) {
|
|
||||||
// needed for JS-Bindings compatibility
|
|
||||||
cc.associateWithNative( this, cc.Sprite );
|
|
||||||
|
|
||||||
this.HP = arg.HP;
|
|
||||||
this.moveType = arg.moveType;
|
|
||||||
this.scoreValue = arg.scoreValue;
|
|
||||||
this.attackMode = arg.attackMode;
|
|
||||||
|
|
||||||
this.initWithSpriteFrameName(arg.textureName);
|
|
||||||
this.schedule(this.shoot, this.delayTime);
|
|
||||||
},
|
|
||||||
_timeTick:0,
|
|
||||||
update:function (dt) {
|
|
||||||
if (this.HP <= 0) {
|
|
||||||
this.active = false;
|
|
||||||
}
|
|
||||||
this._timeTick += dt;
|
|
||||||
if (this._timeTick > 0.1) {
|
|
||||||
this._timeTick = 0;
|
|
||||||
if (this._hurtColorLife > 0) {
|
|
||||||
this._hurtColorLife--;
|
|
||||||
}
|
|
||||||
if (this._hurtColorLife == 1) {
|
|
||||||
this.setColor( cc.WHITE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
destroy:function () {
|
|
||||||
MW.SCORE += this.scoreValue;
|
|
||||||
var a = new Explosion();
|
|
||||||
a.setPosition(this.getPosition());
|
|
||||||
this.getParent().addChild(a);
|
|
||||||
spark(this.getPosition(),this.getParent(), 1.2, 0.7);
|
|
||||||
cc.ArrayRemoveObject(MW.CONTAINER.ENEMIES,this);
|
|
||||||
this.removeFromParentAndCleanup(true);
|
|
||||||
if(MW.SOUND){
|
|
||||||
cc.AudioEngine.getInstance().playEffect(s_explodeEffect);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
shoot:function () {
|
|
||||||
var p = this.getPosition();
|
|
||||||
var b = new Bullet(this.bulletSpeed, "W2.png", this.attackMode);
|
|
||||||
MW.CONTAINER.ENEMY_BULLETS.push(b);
|
|
||||||
this.getParent().addChild(b, b.zOrder, MW.UNIT_TAG.ENMEY_BULLET);
|
|
||||||
b.setPosition(cc.p(p.x, p.y - this.getContentSize().height * 0.2));
|
|
||||||
},
|
|
||||||
hurt:function () {
|
|
||||||
this._hurtColorLife = 2;
|
|
||||||
this.HP--;
|
|
||||||
this.setColor( cc.RED );
|
|
||||||
},
|
|
||||||
collideRect:function(){
|
|
||||||
var a = this.getContentSize();
|
|
||||||
var p = this.getPosition();
|
|
||||||
return cc.rect(p.x - a.width/2, p.y - a.height/4,a.width,a.height/2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Enemy.sharedEnemy = function(){
|
|
||||||
cc.SpriteFrameCache.getInstance().addSpriteFrames(s_Enemy_plist, s_Enemy);
|
|
||||||
};
|
|
|
@ -1,38 +0,0 @@
|
||||||
var Explosion = cc.Sprite.extend({
|
|
||||||
tmpWidth:0,
|
|
||||||
tmpHeight:0,
|
|
||||||
ctor:function () {
|
|
||||||
// needed for JS-Bindings compatibility
|
|
||||||
cc.associateWithNative( this, cc.Sprite );
|
|
||||||
|
|
||||||
var pFrame = cc.SpriteFrameCache.getInstance().getSpriteFrame("explosion_01.png");
|
|
||||||
this.initWithSpriteFrame(pFrame);
|
|
||||||
|
|
||||||
var cs = this.getContentSize();
|
|
||||||
this.tmpWidth = cs.width;
|
|
||||||
this.tmpHeight = cs.height;
|
|
||||||
|
|
||||||
var animation = cc.AnimationCache.getInstance().getAnimation("Explosion");
|
|
||||||
this.runAction(cc.Sequence.create(
|
|
||||||
cc.Animate.create(animation),
|
|
||||||
cc.CallFunc.create(this, this.destroy)
|
|
||||||
));
|
|
||||||
this.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
||||||
},
|
|
||||||
destroy:function () {
|
|
||||||
this.getParent().removeChild(this,true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Explosion.sharedExplosion = function () {
|
|
||||||
cc.SpriteFrameCache.getInstance().addSpriteFrames(s_explosion_plist);
|
|
||||||
var animFrames = [];
|
|
||||||
var str = "";
|
|
||||||
for (var i = 1; i < 35; i++) {
|
|
||||||
str = "explosion_" + (i < 10 ? ("0" + i) : i) + ".png";
|
|
||||||
var frame = cc.SpriteFrameCache.getInstance().getSpriteFrame(str);
|
|
||||||
animFrames.push(frame);
|
|
||||||
}
|
|
||||||
var animation = cc.Animation.create(animFrames, 0.04);
|
|
||||||
cc.AnimationCache.getInstance().addAnimation(animation, "Explosion");
|
|
||||||
};
|
|
|
@ -1,35 +0,0 @@
|
||||||
var GameControlMenu = cc.Layer.extend({
|
|
||||||
ctor:function() {
|
|
||||||
// needed for JS-Bindings compatibility
|
|
||||||
cc.associateWithNative( this, cc.Layer);
|
|
||||||
},
|
|
||||||
init:function () {
|
|
||||||
var bRet = false;
|
|
||||||
if (this._super()) {
|
|
||||||
cc.MenuItemFont.setFontSize(18);
|
|
||||||
cc.MenuItemFont.setFontName("Arial");
|
|
||||||
var systemMenu = cc.MenuItemFont.create("Main Menu", this, this.sysMenu);
|
|
||||||
var menu = cc.Menu.create(systemMenu);
|
|
||||||
menu.setPosition(cc.p(0, 0));
|
|
||||||
systemMenu.setAnchorPoint(cc.p(0, 0));
|
|
||||||
systemMenu.setPosition(cc.p(winSize.width-95, 5));
|
|
||||||
this.addChild(menu, 1, 2);
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
},
|
|
||||||
sysMenu:function (pSender) {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
scene.addChild(SysMenu.create());
|
|
||||||
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2,scene));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
GameControlMenu.create = function () {
|
|
||||||
var sg = new GameControlMenu();
|
|
||||||
if (sg && sg.init()) {
|
|
||||||
return sg;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
|
@ -1,70 +0,0 @@
|
||||||
/**
|
|
||||||
* Cocos2d-html5 show case : Moon Warriors
|
|
||||||
*
|
|
||||||
* @Licensed:
|
|
||||||
* This showcase is licensed under GPL.
|
|
||||||
*
|
|
||||||
* @Authors:
|
|
||||||
* Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada
|
|
||||||
* Effects animation: Hao Wu (吴昊)
|
|
||||||
* Quality Assurance: Sean Lin (林顺)
|
|
||||||
*
|
|
||||||
* @Links:
|
|
||||||
* http://www.cocos2d-x.org
|
|
||||||
* http://bbs.html5china.com
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
MW.GameController = cc.Class.extend({
|
|
||||||
_curScene:null,
|
|
||||||
_gameState:MW.GAME_STATE.HOME,
|
|
||||||
_isNewGame:true,
|
|
||||||
_curLevel:MW.LEVEL.STAGE1,
|
|
||||||
_selectLevel:MW.LEVEL.STAGE1,
|
|
||||||
init:function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
setCurScene:function (s) {
|
|
||||||
if (this._curScene != s) {
|
|
||||||
if (this._curScene !== null) {
|
|
||||||
this._curScene.onExit();
|
|
||||||
}
|
|
||||||
this._curScene = s;
|
|
||||||
if (this._curScene) {
|
|
||||||
this._curScene.onEnter();
|
|
||||||
cc.Director.getInstance().replaceScene(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getCurScene:function () {
|
|
||||||
return this._curScene;
|
|
||||||
},
|
|
||||||
runGame:function () {
|
|
||||||
|
|
||||||
},
|
|
||||||
newGame:function () {
|
|
||||||
|
|
||||||
},
|
|
||||||
option:function () {
|
|
||||||
|
|
||||||
},
|
|
||||||
about:function () {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
MW.GameController.getInstance = function () {
|
|
||||||
cc.Assert(this._sharedGame, "Havn't call setSharedGame");
|
|
||||||
if (!this._sharedGame) {
|
|
||||||
this._sharedGame = new MW.GameController();
|
|
||||||
if (this._sharedGame.init()) {
|
|
||||||
return this._sharedGame;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return this._sharedGame;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
MW.GameController._sharedGame = null;
|
|
|
@ -1,315 +0,0 @@
|
||||||
//
|
|
||||||
// MoonWarriors
|
|
||||||
//
|
|
||||||
// Handles the Game Logic
|
|
||||||
//
|
|
||||||
|
|
||||||
STATE_PLAYING = 0;
|
|
||||||
STATE_GAMEOVER = 1;
|
|
||||||
|
|
||||||
var GameLayer = cc.Layer.extend({
|
|
||||||
_time:null,
|
|
||||||
_ship:null,
|
|
||||||
_backSky:null,
|
|
||||||
_backSkyHeight:0,
|
|
||||||
_backSkyRe:null,
|
|
||||||
_backTileMap:null,
|
|
||||||
_backTileMapHeight:0,
|
|
||||||
_backTileMapRe:null,
|
|
||||||
_levelManager:null,
|
|
||||||
_tmpScore:0,
|
|
||||||
_isBackSkyReload:false,
|
|
||||||
_isBackTileReload:false,
|
|
||||||
lbScore:null,
|
|
||||||
screenRect:null,
|
|
||||||
explosionAnimation:[],
|
|
||||||
_beginPos:cc.p(0, 0),
|
|
||||||
_state:STATE_PLAYING,
|
|
||||||
ctor:function () {
|
|
||||||
cc.associateWithNative( this, cc.Layer );
|
|
||||||
},
|
|
||||||
init:function () {
|
|
||||||
var bRet = false;
|
|
||||||
if (this._super()) {
|
|
||||||
|
|
||||||
// reset global values
|
|
||||||
MW.CONTAINER.ENEMIES = [];
|
|
||||||
MW.CONTAINER.ENEMY_BULLETS = [];
|
|
||||||
MW.CONTAINER.PLAYER_BULLETS = [];
|
|
||||||
MW.SCORE = 0;
|
|
||||||
MW.LIFE = 4;
|
|
||||||
this._state = STATE_PLAYING;
|
|
||||||
|
|
||||||
Explosion.sharedExplosion();
|
|
||||||
Enemy.sharedEnemy();
|
|
||||||
winSize = cc.Director.getInstance().getWinSize();
|
|
||||||
this._levelManager = new LevelManager(this);
|
|
||||||
this.initBackground();
|
|
||||||
this.screenRect = cc.rect(0, 0, winSize.width, winSize.height + 10);
|
|
||||||
|
|
||||||
// score
|
|
||||||
this.lbScore = cc.LabelBMFont.create("Score: 0", s_arial14_fnt);
|
|
||||||
this.lbScore.setAnchorPoint( cc.p(1,0) );
|
|
||||||
this.lbScore.setAlignment( cc.TEXT_ALIGNMENT_RIGHT );
|
|
||||||
this.addChild(this.lbScore, 1000);
|
|
||||||
this.lbScore.setPosition(cc.p(winSize.width - 5 , winSize.height - 30));
|
|
||||||
|
|
||||||
// ship life
|
|
||||||
var shipTexture = cc.TextureCache.getInstance().addImage(s_ship01);
|
|
||||||
var life = cc.Sprite.createWithTexture(shipTexture, cc.rect(0, 0, 60, 38));
|
|
||||||
life.setScale(0.6);
|
|
||||||
life.setPosition(cc.p(30, 460));
|
|
||||||
this.addChild(life, 1, 5);
|
|
||||||
|
|
||||||
// ship Life count
|
|
||||||
this._lbLife = cc.LabelTTF.create("0", "Arial", 20);
|
|
||||||
this._lbLife.setPosition(cc.p(60, 463));
|
|
||||||
this._lbLife.setColor(cc.RED);
|
|
||||||
this.addChild(this._lbLife, 1000);
|
|
||||||
|
|
||||||
// ship
|
|
||||||
this._ship = new Ship();
|
|
||||||
this.addChild(this._ship, this._ship.zOrder, MW.UNIT_TAG.PLAYER);
|
|
||||||
|
|
||||||
// accept touch now!
|
|
||||||
|
|
||||||
var t = cc.config.deviceType;
|
|
||||||
if( t == 'browser' ) {
|
|
||||||
this.setTouchEnabled(true);
|
|
||||||
this.setKeyboardEnabled(true);
|
|
||||||
} else if( t == 'desktop' ) {
|
|
||||||
this.setMouseEnabled(true);
|
|
||||||
} else if( t == 'mobile' ) {
|
|
||||||
this.setTouchEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// schedule
|
|
||||||
this.scheduleUpdate();
|
|
||||||
this.schedule(this.scoreCounter, 1);
|
|
||||||
|
|
||||||
if (MW.SOUND) {
|
|
||||||
cc.AudioEngine.getInstance().playBackgroundMusic(s_bgMusic, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
return bRet;
|
|
||||||
},
|
|
||||||
scoreCounter:function () {
|
|
||||||
if( this._state == STATE_PLAYING ) {
|
|
||||||
this._time++;
|
|
||||||
|
|
||||||
var minute = 0 | (this._time / 60);
|
|
||||||
var second = this._time % 60;
|
|
||||||
minute = minute > 9 ? minute : "0" + minute;
|
|
||||||
second = second > 9 ? second : "0" + second;
|
|
||||||
var curTime = minute + ":" + second;
|
|
||||||
this._levelManager.loadLevelResource(this._time);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onTouchesMoved:function (touches, event) {
|
|
||||||
this.processEvent( touches[0] );
|
|
||||||
},
|
|
||||||
|
|
||||||
onMouseDragged:function( event ) {
|
|
||||||
this.processEvent( event );
|
|
||||||
},
|
|
||||||
|
|
||||||
processEvent:function( event ) {
|
|
||||||
if( this._state == STATE_PLAYING ) {
|
|
||||||
var delta = event.getDelta();
|
|
||||||
var curPos = this._ship.getPosition();
|
|
||||||
curPos= cc.pAdd( curPos, delta );
|
|
||||||
curPos = cc.pClamp(curPos, cc.POINT_ZERO, cc.p(winSize.width, winSize.height) );
|
|
||||||
this._ship.setPosition( curPos );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onKeyDown:function (e) {
|
|
||||||
MW.KEYS[e] = true;
|
|
||||||
},
|
|
||||||
|
|
||||||
onKeyUp:function (e) {
|
|
||||||
MW.KEYS[e] = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
update:function (dt) {
|
|
||||||
if( this._state == STATE_PLAYING ) {
|
|
||||||
this.checkIsCollide();
|
|
||||||
this.removeInactiveUnit(dt);
|
|
||||||
this.checkIsReborn();
|
|
||||||
this.updateUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cc.config.deviceType == '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 () {
|
|
||||||
var selChild, bulletChild;
|
|
||||||
//check collide
|
|
||||||
var i =0;
|
|
||||||
for (i = 0; i < MW.CONTAINER.ENEMIES.length; i++) {
|
|
||||||
selChild = MW.CONTAINER.ENEMIES[i];
|
|
||||||
for (var j = 0; j < MW.CONTAINER.PLAYER_BULLETS.length; j++) {
|
|
||||||
bulletChild = MW.CONTAINER.PLAYER_BULLETS[j];
|
|
||||||
if (this.collide(selChild, bulletChild)) {
|
|
||||||
bulletChild.hurt();
|
|
||||||
selChild.hurt();
|
|
||||||
}
|
|
||||||
if (!cc.rectIntersectsRect(this.screenRect, bulletChild.getBoundingBox() )) {
|
|
||||||
bulletChild.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.collide(selChild, this._ship)) {
|
|
||||||
if (this._ship.active) {
|
|
||||||
selChild.hurt();
|
|
||||||
this._ship.hurt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!cc.rectIntersectsRect(this.screenRect, selChild.getBoundingBox() )) {
|
|
||||||
selChild.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < MW.CONTAINER.ENEMY_BULLETS.length; i++) {
|
|
||||||
selChild = MW.CONTAINER.ENEMY_BULLETS[i];
|
|
||||||
if (this.collide(selChild, this._ship)) {
|
|
||||||
if (this._ship.active) {
|
|
||||||
selChild.hurt();
|
|
||||||
this._ship.hurt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!cc.rectIntersectsRect(this.screenRect, selChild.getBoundingBox() )) {
|
|
||||||
selChild.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeInactiveUnit:function (dt) {
|
|
||||||
var selChild, layerChildren = this.getChildren();
|
|
||||||
for (var i in layerChildren) {
|
|
||||||
selChild = layerChildren[i];
|
|
||||||
if (selChild) {
|
|
||||||
if( typeof selChild.update == 'function' ) {
|
|
||||||
selChild.update(dt);
|
|
||||||
var tag = selChild.getTag();
|
|
||||||
if ((tag == MW.UNIT_TAG.PLAYER) || (tag == MW.UNIT_TAG.PLAYER_BULLET) ||
|
|
||||||
(tag == MW.UNIT_TAG.ENEMY) || (tag == MW.UNIT_TAG.ENMEY_BULLET)) {
|
|
||||||
if (selChild && !selChild.active) {
|
|
||||||
selChild.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
checkIsReborn:function () {
|
|
||||||
if (MW.LIFE > 0 && !this._ship.active) {
|
|
||||||
// ship
|
|
||||||
this._ship = new Ship();
|
|
||||||
this.addChild(this._ship, this._ship.zOrder, MW.UNIT_TAG.PLAYER);
|
|
||||||
}
|
|
||||||
else if (MW.LIFE <= 0 && !this._ship.active) {
|
|
||||||
this._state = STATE_GAMEOVER;
|
|
||||||
// XXX: needed for JS bindings.
|
|
||||||
this._ship = null;
|
|
||||||
this.runAction(cc.Sequence.create(
|
|
||||||
cc.DelayTime.create(0.2),
|
|
||||||
cc.CallFunc.create(this, this.onGameOver)));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateUI:function () {
|
|
||||||
if (this._tmpScore < MW.SCORE) {
|
|
||||||
this._tmpScore += 5;
|
|
||||||
}
|
|
||||||
this._lbLife.setString(MW.LIFE);
|
|
||||||
this.lbScore.setString("Score: " + this._tmpScore);
|
|
||||||
},
|
|
||||||
collide:function (a, b) {
|
|
||||||
var aRect = a.collideRect();
|
|
||||||
var bRect = b.collideRect();
|
|
||||||
if (cc.rectIntersectsRect(aRect, bRect)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
initBackground:function () {
|
|
||||||
// bg
|
|
||||||
this._backSky = cc.Sprite.create(s_bg01);
|
|
||||||
this._backSky.setAnchorPoint(cc.p(0, 0));
|
|
||||||
this._backSkyHeight = this._backSky.getContentSize().height;
|
|
||||||
this.addChild(this._backSky, -10);
|
|
||||||
|
|
||||||
//tilemap
|
|
||||||
this._backTileMap = cc.TMXTiledMap.create(s_level01);
|
|
||||||
this.addChild(this._backTileMap, -9);
|
|
||||||
this._backTileMapHeight = this._backTileMap.getMapSize().height * this._backTileMap.getTileSize().height;
|
|
||||||
|
|
||||||
this._backSkyHeight -= 48;
|
|
||||||
this._backTileMapHeight -= 200;
|
|
||||||
this._backSky.runAction(cc.MoveBy.create(3, cc.p(0, -48)));
|
|
||||||
this._backTileMap.runAction(cc.MoveBy.create(3, cc.p(0, -200)));
|
|
||||||
|
|
||||||
this.schedule(this.movingBackground, 3);
|
|
||||||
},
|
|
||||||
movingBackground:function () {
|
|
||||||
this._backSky.runAction(cc.MoveBy.create(3, cc.p(0, -48)));
|
|
||||||
this._backTileMap.runAction(cc.MoveBy.create(3, cc.p(0, -200)));
|
|
||||||
this._backSkyHeight -= 48;
|
|
||||||
this._backTileMapHeight -= 200;
|
|
||||||
|
|
||||||
if (this._backSkyHeight <= winSize.height) {
|
|
||||||
if (!this._isBackSkyReload) {
|
|
||||||
this._backSkyRe = cc.Sprite.create(s_bg01);
|
|
||||||
this._backSkyRe.setAnchorPoint(cc.p(0, 0));
|
|
||||||
this.addChild(this._backSkyRe, -10);
|
|
||||||
this._backSkyRe.setPosition(cc.p(0, winSize.height));
|
|
||||||
this._isBackSkyReload = true;
|
|
||||||
}
|
|
||||||
this._backSkyRe.runAction(cc.MoveBy.create(3, cc.p(0, -48)));
|
|
||||||
}
|
|
||||||
if (this._backSkyHeight <= 0) {
|
|
||||||
this._backSkyHeight = this._backSky.getContentSize().height;
|
|
||||||
this.removeChild(this._backSky, true);
|
|
||||||
this._backSky = this._backSkyRe;
|
|
||||||
this._backSkyRe = null;
|
|
||||||
this._isBackSkyReload = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._backTileMapHeight <= winSize.height) {
|
|
||||||
if (!this._isBackTileReload) {
|
|
||||||
this._backTileMapRe = cc.TMXTiledMap.create(s_level01);
|
|
||||||
this.addChild(this._backTileMapRe, -9);
|
|
||||||
this._backTileMapRe.setPosition(cc.p(0, winSize.height));
|
|
||||||
this._isBackTileReload = true;
|
|
||||||
}
|
|
||||||
this._backTileMapRe.runAction(cc.MoveBy.create(3, cc.p(0, -200)));
|
|
||||||
}
|
|
||||||
if (this._backTileMapHeight <= 0) {
|
|
||||||
this._backTileMapHeight = this._backTileMapRe.getMapSize().height * this._backTileMapRe.getTileSize().height;
|
|
||||||
this.removeChild(this._backTileMap, true);
|
|
||||||
this._backTileMap = this._backTileMapRe;
|
|
||||||
this._backTileMapRe = null;
|
|
||||||
this._isBackTileReload = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onGameOver:function () {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
scene.addChild(GameOver.create());
|
|
||||||
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2, scene));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
GameLayer.create = function () {
|
|
||||||
var sg = new GameLayer();
|
|
||||||
if (sg && sg.init()) {
|
|
||||||
return sg;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameLayer.scene = function () {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
var layer = GameLayer.create();
|
|
||||||
scene.addChild(layer, 1);
|
|
||||||
return scene;
|
|
||||||
};
|
|
|
@ -1,83 +0,0 @@
|
||||||
var GameOver = cc.Layer.extend({
|
|
||||||
_ship:null,
|
|
||||||
_lbScore:0,
|
|
||||||
ctor:function() {
|
|
||||||
// needed for JS-Bindings compatibility
|
|
||||||
cc.associateWithNative( this, cc.Layer);
|
|
||||||
},
|
|
||||||
init:function () {
|
|
||||||
var bRet = false;
|
|
||||||
if (this._super()) {
|
|
||||||
var sp = cc.Sprite.create(s_loading);
|
|
||||||
sp.setAnchorPoint( cc.p(0,0) );
|
|
||||||
this.addChild(sp, 0, 1);
|
|
||||||
|
|
||||||
var logo = cc.Sprite.create(s_gameOver);
|
|
||||||
logo.setAnchorPoint(cc.p(0,0));
|
|
||||||
logo.setPosition(cc.p(0,300));
|
|
||||||
this.addChild(logo,10,1);
|
|
||||||
|
|
||||||
var playAgainNormal = cc.Sprite.create(s_menu, cc.rect(378, 0, 126, 33));
|
|
||||||
var playAgainSelected = cc.Sprite.create(s_menu, cc.rect(378, 33, 126, 33));
|
|
||||||
var playAgainDisabled = cc.Sprite.create(s_menu, cc.rect(378, 33 * 2, 126, 33));
|
|
||||||
|
|
||||||
var cocos2dhtml5 = cc.Sprite.create(s_cocos2dhtml5);
|
|
||||||
cocos2dhtml5.setPosition(cc.p(160,150));
|
|
||||||
this.addChild(cocos2dhtml5,10);
|
|
||||||
var playAgain = cc.MenuItemSprite.create(playAgainNormal, playAgainSelected, playAgainDisabled, this, function(){
|
|
||||||
flareEffect(this,this,this.onPlayAgain);
|
|
||||||
});
|
|
||||||
|
|
||||||
var menu = cc.Menu.create(playAgain);
|
|
||||||
this.addChild(menu, 1, 2);
|
|
||||||
menu.setPosition(cc.p(winSize.width / 2, 220));
|
|
||||||
|
|
||||||
var lbScore = cc.LabelTTF.create("Your Score:"+MW.SCORE,"Arial Bold",16);
|
|
||||||
lbScore.setPosition(cc.p(160,280));
|
|
||||||
lbScore.setColor(cc.c3b(250,179,0));
|
|
||||||
this.addChild(lbScore,10);
|
|
||||||
|
|
||||||
var b1 = cc.LabelTTF.create("Download Cocos2d-html5","Arial",14);
|
|
||||||
var b2 = cc.LabelTTF.create("Download This Sample","Arial",14);
|
|
||||||
var menu1 = cc.MenuItemLabel.create(b1,this,function(){
|
|
||||||
window.location.href = "http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d-html5";
|
|
||||||
});
|
|
||||||
var menu2 = cc.MenuItemLabel.create(b2,this,function(){
|
|
||||||
window.location.href = "https://github.com/ShengxiangChen/MoonWarriors";
|
|
||||||
});
|
|
||||||
var cocos2dMenu = cc.Menu.create(menu1,menu2);
|
|
||||||
cocos2dMenu.alignItemsVerticallyWithPadding(10);
|
|
||||||
cocos2dMenu.setPosition(cc.p(160,80));
|
|
||||||
this.addChild(cocos2dMenu);
|
|
||||||
|
|
||||||
|
|
||||||
if(MW.SOUND){
|
|
||||||
cc.AudioEngine.getInstance().playBackgroundMusic(s_mainMainMusic);
|
|
||||||
}
|
|
||||||
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
return bRet;
|
|
||||||
},
|
|
||||||
onPlayAgain:function (pSender) {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
scene.addChild(GameLayer.create());
|
|
||||||
scene.addChild(GameControlMenu.create());
|
|
||||||
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2,scene));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
GameOver.create = function () {
|
|
||||||
var sg = new GameOver();
|
|
||||||
if (sg && sg.init()) {
|
|
||||||
return sg;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
GameOver.scene = function () {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
var layer = GameOver.create();
|
|
||||||
scene.addChild(layer);
|
|
||||||
return scene;
|
|
||||||
};
|
|
|
@ -1,99 +0,0 @@
|
||||||
var LevelManager = cc.Class.extend({
|
|
||||||
_currentLevel:null,
|
|
||||||
_gameLayer:null,
|
|
||||||
ctor:function(gameLayer){
|
|
||||||
if(!gameLayer){
|
|
||||||
throw "gameLayer must be non-nil";
|
|
||||||
}
|
|
||||||
this._currentLevel = Level1;
|
|
||||||
this._gameLayer = gameLayer;
|
|
||||||
this.setLevel(this._currentLevel);
|
|
||||||
},
|
|
||||||
|
|
||||||
setLevel:function(level){
|
|
||||||
for(var i = 0; i< level.enemies.length; i++){
|
|
||||||
this._currentLevel.enemies[i].ShowTime = this._minuteToSecond(this._currentLevel.enemies[i].ShowTime);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_minuteToSecond:function(minuteStr){
|
|
||||||
if(!minuteStr)
|
|
||||||
return 0;
|
|
||||||
if(typeof(minuteStr) != "number"){
|
|
||||||
var mins = minuteStr.split(':');
|
|
||||||
if(mins.length == 1){
|
|
||||||
return parseInt(mins[0],10);
|
|
||||||
}else {
|
|
||||||
return parseInt(mins[0],10 )* 60 + parseInt(mins[1],10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return minuteStr;
|
|
||||||
},
|
|
||||||
|
|
||||||
loadLevelResource:function(deltaTime){
|
|
||||||
//load enemy
|
|
||||||
for(var i = 0; i< this._currentLevel.enemies.length; i++){
|
|
||||||
var selEnemy = this._currentLevel.enemies[i];
|
|
||||||
if(selEnemy){
|
|
||||||
if(selEnemy.ShowType == "Once"){
|
|
||||||
if(selEnemy.ShowTime == deltaTime){
|
|
||||||
for(var tIndex = 0; tIndex < selEnemy.Types.length;tIndex++ ){
|
|
||||||
this.addEnemyToGameLayer(selEnemy.Types[tIndex]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(selEnemy.ShowType == "Repeate"){
|
|
||||||
if(deltaTime % selEnemy.ShowTime === 0){
|
|
||||||
for(var rIndex = 0; rIndex < selEnemy.Types.length;rIndex++ ){
|
|
||||||
this.addEnemyToGameLayer(selEnemy.Types[rIndex]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
addEnemyToGameLayer:function(enemyType){
|
|
||||||
var addEnemy = new Enemy(EnemyType[enemyType]);
|
|
||||||
|
|
||||||
var enemypos = cc.p( 80 + (winSize.width - 160) * Math.random(), winSize.height);
|
|
||||||
var enemycs = addEnemy.getContentSize();
|
|
||||||
addEnemy.setPosition( enemypos );
|
|
||||||
|
|
||||||
|
|
||||||
var offset, tmpAction;
|
|
||||||
var a0=0;
|
|
||||||
var a1=0;
|
|
||||||
switch (addEnemy.moveType) {
|
|
||||||
case MW.ENEMY_MOVE_TYPE.ATTACK:
|
|
||||||
offset = this._gameLayer._ship.getPosition();
|
|
||||||
tmpAction = cc.MoveTo.create(1, offset);
|
|
||||||
break;
|
|
||||||
case MW.ENEMY_MOVE_TYPE.VERTICAL:
|
|
||||||
offset = cc.p(0, -winSize.height - enemycs.height);
|
|
||||||
tmpAction = cc.MoveBy.create(4, offset);
|
|
||||||
break;
|
|
||||||
case MW.ENEMY_MOVE_TYPE.HORIZONTAL:
|
|
||||||
offset = cc.p(0, -100 - 200 * Math.random());
|
|
||||||
a0 = cc.MoveBy.create(0.5, offset);
|
|
||||||
a1 = cc.MoveBy.create(1, cc.p(-50 - 100 * Math.random(), 0));
|
|
||||||
var onComplete = cc.CallFunc.create(addEnemy, function (pSender) {
|
|
||||||
var a2 = cc.DelayTime.create(1);
|
|
||||||
var a3 = cc.MoveBy.create(1, cc.p(100 + 100 * Math.random(), 0));
|
|
||||||
pSender.runAction(cc.RepeatForever.create(
|
|
||||||
cc.Sequence.create(a2, a3, a2.copy(), a3.reverse())
|
|
||||||
));
|
|
||||||
});
|
|
||||||
tmpAction = cc.Sequence.create(a0, a1, onComplete);
|
|
||||||
break;
|
|
||||||
case MW.ENEMY_MOVE_TYPE.OVERLAP:
|
|
||||||
var newX = (enemypos.x <= winSize.width / 2) ? 320 : -320;
|
|
||||||
a0 = cc.MoveBy.create(4, cc.p(newX, -240));
|
|
||||||
a1 = cc.MoveBy.create(4,cc.p(-newX,-320));
|
|
||||||
tmpAction = cc.Sequence.create(a0,a1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._gameLayer.addChild(addEnemy, addEnemy.zOrder, MW.UNIT_TAG.ENEMY);
|
|
||||||
MW.CONTAINER.ENEMIES.push(addEnemy);
|
|
||||||
addEnemy.runAction(tmpAction);
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,89 +0,0 @@
|
||||||
var dirImg = "";
|
|
||||||
var dirMusic = "";
|
|
||||||
var musicSuffix = ".mp3";
|
|
||||||
if( cc.config.deviceType == 'browser' || cc.config.engine == 'cocos2d-x') {
|
|
||||||
dirImg = "MoonWarriors/res/";
|
|
||||||
dirMusic = "MoonWarriors/res/Music/";
|
|
||||||
musicSuffix = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//image
|
|
||||||
var s_bg01 = dirImg + "bg01.jpg";
|
|
||||||
var s_loading = dirImg + "loading.png";
|
|
||||||
var s_ship01 = dirImg + "ship01.png";
|
|
||||||
var s_menu = dirImg + "menu.png";
|
|
||||||
var s_logo = dirImg + "logo.png";
|
|
||||||
var s_cocos2dhtml5 = dirImg + "cocos2d-html5.png";
|
|
||||||
var s_gameOver = dirImg + "gameOver.png";
|
|
||||||
var s_menuTitle = dirImg + "menuTitle.png";
|
|
||||||
var s_Enemy = dirImg + "Enemy.png";
|
|
||||||
var s_flare = dirImg + "flare.jpg";
|
|
||||||
var s_bullet = dirImg + "bullet.png";
|
|
||||||
var s_explosion = dirImg + "explosion.png";
|
|
||||||
var s_explode1 = dirImg + "explode1.jpg";
|
|
||||||
var s_explode2= dirImg + "explode2.jpg";
|
|
||||||
var s_explode3 = dirImg + "explode3.jpg";
|
|
||||||
var s_hit = dirImg + "hit.jpg";
|
|
||||||
var s_arial14 = dirImg + "arial-14.png";
|
|
||||||
var s_arial14_fnt = dirImg + "arial-14.fnt";
|
|
||||||
|
|
||||||
//music
|
|
||||||
var s_bgMusic = dirMusic + "bgMusic" + musicSuffix;
|
|
||||||
var s_mainMainMusic = dirMusic + "mainMainMusic" + musicSuffix;
|
|
||||||
|
|
||||||
//effect
|
|
||||||
var s_buttonEffect = dirMusic + "buttonEffet" + musicSuffix;
|
|
||||||
var s_explodeEffect = dirMusic + "explodeEffect" + musicSuffix;
|
|
||||||
var s_fireEffect = dirMusic + "fireEffect" + musicSuffix;
|
|
||||||
var s_shipDestroyEffect = dirMusic + "shipDestroyEffect" + musicSuffix;
|
|
||||||
|
|
||||||
//tmx
|
|
||||||
var s_level01 = dirImg + "level01.tmx";
|
|
||||||
|
|
||||||
//plist
|
|
||||||
var s_Enemy_plist = dirImg + "Enemy.plist";
|
|
||||||
var s_explosion_plist = dirImg + "explosion.plist";
|
|
||||||
var s_bullet_plist = dirImg + "bullet.plist";
|
|
||||||
|
|
||||||
var g_ressources = [
|
|
||||||
//image
|
|
||||||
{type:"image", src:s_bg01},
|
|
||||||
{type:"image", src:s_loading},
|
|
||||||
{type:"image", src:s_ship01},
|
|
||||||
{type:"image", src:s_menu},
|
|
||||||
{type:"image", src:s_logo},
|
|
||||||
{type:"image", src:s_cocos2dhtml5},
|
|
||||||
{type:"image", src:s_gameOver},
|
|
||||||
{type:"image", src:s_menuTitle},
|
|
||||||
{type:"image", src:s_Enemy},
|
|
||||||
{type:"image", src:s_flare},
|
|
||||||
{type:"image", src:s_bullet},
|
|
||||||
{type:"image", src:s_explosion},
|
|
||||||
{type:"image", src:s_explode1},
|
|
||||||
{type:"image", src:s_explode2},
|
|
||||||
{type:"image", src:s_explode3},
|
|
||||||
{type:"image", src:s_hit},
|
|
||||||
{type:"image", src:s_arial14},
|
|
||||||
|
|
||||||
//tmx
|
|
||||||
{type:"tmx", src:s_level01},
|
|
||||||
|
|
||||||
//plist
|
|
||||||
{type:"plist", src:s_Enemy_plist},
|
|
||||||
{type:"plist", src:s_explosion_plist},
|
|
||||||
{type:"plist", src:s_bullet_plist},
|
|
||||||
|
|
||||||
//music
|
|
||||||
{type:"bgm", src:s_bgMusic},
|
|
||||||
{type:"bgm", src:s_mainMainMusic},
|
|
||||||
|
|
||||||
//effect
|
|
||||||
{type:"effect", src:s_buttonEffect},
|
|
||||||
{type:"effect", src:s_explodeEffect},
|
|
||||||
{type:"effect", src:s_fireEffect},
|
|
||||||
{type:"effect", src:s_shipDestroyEffect},
|
|
||||||
|
|
||||||
// FNT
|
|
||||||
{type:"fnt", src:s_arial14_fnt}
|
|
||||||
|
|
||||||
];
|
|
|
@ -1,85 +0,0 @@
|
||||||
var SettingsLayer = cc.Layer.extend({
|
|
||||||
ctor:function () {
|
|
||||||
cc.associateWithNative( this, cc.Layer );
|
|
||||||
},
|
|
||||||
init:function () {
|
|
||||||
var bRet = false;
|
|
||||||
if (this._super()) {
|
|
||||||
var sp = cc.Sprite.create(s_loading);
|
|
||||||
sp.setAnchorPoint(cc.p(0,0));
|
|
||||||
this.addChild(sp, 0, 1);
|
|
||||||
|
|
||||||
var cacheImage = cc.TextureCache.getInstance().addImage(s_menuTitle);
|
|
||||||
var title = cc.Sprite.createWithTexture(cacheImage, cc.rect(0, 0, 134, 34));
|
|
||||||
title.setPosition(cc.p(winSize.width / 2, winSize.height - 120));
|
|
||||||
this.addChild(title);
|
|
||||||
|
|
||||||
|
|
||||||
cc.MenuItemFont.setFontName("Arial");
|
|
||||||
cc.MenuItemFont.setFontSize(18);
|
|
||||||
var title1 = cc.MenuItemFont.create("Sound");
|
|
||||||
title1.setEnabled(false);
|
|
||||||
|
|
||||||
cc.MenuItemFont.setFontName("Arial");
|
|
||||||
cc.MenuItemFont.setFontSize(26);
|
|
||||||
var item1 = cc.MenuItemToggle.create(
|
|
||||||
cc.MenuItemFont.create("On"),
|
|
||||||
cc.MenuItemFont.create("Off") );
|
|
||||||
item1.setCallback(this, this.soundControl );
|
|
||||||
|
|
||||||
cc.MenuItemFont.setFontName("Arial");
|
|
||||||
cc.MenuItemFont.setFontSize(18);
|
|
||||||
var title2 = cc.MenuItemFont.create("Mode");
|
|
||||||
title2.setEnabled(false);
|
|
||||||
|
|
||||||
cc.MenuItemFont.setFontName("Arial");
|
|
||||||
cc.MenuItemFont.setFontSize(26);
|
|
||||||
var item2 = cc.MenuItemToggle.create(
|
|
||||||
cc.MenuItemFont.create("Easy"),
|
|
||||||
cc.MenuItemFont.create("Normal"),
|
|
||||||
cc.MenuItemFont.create("Hard"));
|
|
||||||
item2.setCallback( this, this.modeControl );
|
|
||||||
|
|
||||||
|
|
||||||
cc.MenuItemFont.setFontName("Arial");
|
|
||||||
cc.MenuItemFont.setFontSize(26);
|
|
||||||
var label = cc.LabelTTF.create("Go back", "Arial", 20);
|
|
||||||
var back = cc.MenuItemLabel.create(label, this, this.backCallback);
|
|
||||||
back.setScale(0.8);
|
|
||||||
|
|
||||||
var menu = cc.Menu.create(title1, title2, item1, item2, back);
|
|
||||||
menu.alignItemsInColumns(2, 2, 1);
|
|
||||||
this.addChild(menu);
|
|
||||||
|
|
||||||
var cp_back = back.getPosition();
|
|
||||||
cp_back.y -= 50.0;
|
|
||||||
back.setPosition(cp_back);
|
|
||||||
|
|
||||||
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
},
|
|
||||||
backCallback:function (pSender) {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
scene.addChild(SysMenu.create());
|
|
||||||
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2, scene));
|
|
||||||
},
|
|
||||||
soundControl:function(){
|
|
||||||
MW.SOUND = MW.SOUND ? false : true;
|
|
||||||
if(!MW.SOUND){
|
|
||||||
cc.AudioEngine.getInstance().stopBackgroundMusic();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modeControl:function(){
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
SettingsLayer.create = function () {
|
|
||||||
var sg = new SettingsLayer();
|
|
||||||
if (sg && sg.init()) {
|
|
||||||
return sg;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
|
@ -1,128 +0,0 @@
|
||||||
var Ship = cc.Sprite.extend({
|
|
||||||
speed:220,
|
|
||||||
bulletSpeed:900,
|
|
||||||
HP:5,
|
|
||||||
bulletTypeValue:1,
|
|
||||||
bulletPowerValue:1,
|
|
||||||
throwBombing:false,
|
|
||||||
canBeAttack:true,
|
|
||||||
isThrowingBomb:false,
|
|
||||||
zOrder:3000,
|
|
||||||
maxBulletPowerValue:4,
|
|
||||||
appearPosition:cc.p(160, 60),
|
|
||||||
_hurtColorLife:0,
|
|
||||||
active:true,
|
|
||||||
ctor:function () {
|
|
||||||
|
|
||||||
// needed for JS-Bindings compatibility
|
|
||||||
cc.associateWithNative( this, cc.Sprite );
|
|
||||||
|
|
||||||
//init life
|
|
||||||
var shipTexture = cc.TextureCache.getInstance().addImage(s_ship01);
|
|
||||||
this.initWithTexture(shipTexture, cc.rect(0, 0, 60, 38));
|
|
||||||
this.setTag(this.zOrder);
|
|
||||||
this.setPosition(this.appearPosition);
|
|
||||||
|
|
||||||
// set frame
|
|
||||||
var frame0 = cc.SpriteFrame.createWithTexture(shipTexture, cc.rect(0, 0, 60, 38));
|
|
||||||
var frame1 = cc.SpriteFrame.createWithTexture(shipTexture, cc.rect(60, 0, 60, 38));
|
|
||||||
|
|
||||||
var animFrames = [];
|
|
||||||
animFrames.push(frame0);
|
|
||||||
animFrames.push(frame1);
|
|
||||||
|
|
||||||
// ship animate
|
|
||||||
var animation = cc.Animation.create(animFrames, 0.1);
|
|
||||||
var animate = cc.Animate.create(animation);
|
|
||||||
this.runAction(cc.RepeatForever.create(animate));
|
|
||||||
this.schedule(this.shoot, 1 / 6);
|
|
||||||
|
|
||||||
//revive effect
|
|
||||||
this.canBeAttack = false;
|
|
||||||
var ghostSprite = cc.Sprite.createWithTexture(shipTexture, cc.rect(0, 45, 60, 38));
|
|
||||||
ghostSprite.setBlendFunc(gl.SRC_ALPHA, gl.ONE);
|
|
||||||
ghostSprite.setScale(8);
|
|
||||||
ghostSprite.setPosition(cc.p(this.getContentSize().width / 2, 12));
|
|
||||||
this.addChild(ghostSprite, 3000, 99999);
|
|
||||||
ghostSprite.runAction(cc.ScaleTo.create(0.5, 1, 1));
|
|
||||||
var blinks = cc.Blink.create(3, 9);
|
|
||||||
var makeBeAttack = cc.CallFunc.create(this, function (t) {
|
|
||||||
t.canBeAttack = true;
|
|
||||||
t.setVisible(true);
|
|
||||||
t.removeChild(ghostSprite,true);
|
|
||||||
});
|
|
||||||
this.runAction(cc.Sequence.create(cc.DelayTime.create(0.5), blinks, makeBeAttack));
|
|
||||||
},
|
|
||||||
update:function (dt) {
|
|
||||||
|
|
||||||
// Keys are only enabled on the browser
|
|
||||||
if( cc.config.deviceType == '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;
|
|
||||||
}
|
|
||||||
if ((MW.KEYS[cc.KEY.s] || MW.KEYS[cc.KEY.down]) && pos.y >= 0) {
|
|
||||||
pos.y -= dt * this.speed;
|
|
||||||
}
|
|
||||||
if ((MW.KEYS[cc.KEY.a] || MW.KEYS[cc.KEY.left]) && pos.x >= 0) {
|
|
||||||
pos.x -= dt * this.speed;
|
|
||||||
}
|
|
||||||
if ((MW.KEYS[cc.KEY.d] || MW.KEYS[cc.KEY.right]) && pos.x <= winSize.width) {
|
|
||||||
pos.x += dt * this.speed;
|
|
||||||
}
|
|
||||||
this.setPosition( pos );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.HP <= 0) {
|
|
||||||
this.active = false;
|
|
||||||
}
|
|
||||||
this._timeTick += dt;
|
|
||||||
if (this._timeTick > 0.1) {
|
|
||||||
this._timeTick = 0;
|
|
||||||
if (this._hurtColorLife > 0) {
|
|
||||||
this._hurtColorLife--;
|
|
||||||
}
|
|
||||||
if (this._hurtColorLife == 1) {
|
|
||||||
this.setColor(cc.WHITE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
shoot:function (dt) {
|
|
||||||
//this.shootEffect();
|
|
||||||
var offset = 13;
|
|
||||||
var p = this.getPosition();
|
|
||||||
var cs = this.getContentSize();
|
|
||||||
var a = new Bullet(this.bulletSpeed, "W1.png", MW.ENEMY_MOVE_TYPE.NORMAL);
|
|
||||||
MW.CONTAINER.PLAYER_BULLETS.push(a);
|
|
||||||
this.getParent().addChild(a, a.zOrder, MW.UNIT_TAG.PLAYER_BULLET);
|
|
||||||
a.setPosition(cc.p(p.x + offset, p.y + 3 + cs.height * 0.3));
|
|
||||||
|
|
||||||
var b = new Bullet(this.bulletSpeed, "W1.png", MW.ENEMY_MOVE_TYPE.NORMAL);
|
|
||||||
MW.CONTAINER.PLAYER_BULLETS.push(b);
|
|
||||||
this.getParent().addChild(b, b.zOrder, MW.UNIT_TAG.PLAYER_BULLET);
|
|
||||||
b.setPosition(cc.p(p.x - offset, p.y + 3 + cs.height * 0.3));
|
|
||||||
},
|
|
||||||
destroy:function () {
|
|
||||||
MW.LIFE--;
|
|
||||||
var p = this.getPosition();
|
|
||||||
var myParent = this.getParent();
|
|
||||||
myParent.addChild( new Explosion(p) );
|
|
||||||
myParent.removeChild(this,true);
|
|
||||||
if (MW.SOUND) {
|
|
||||||
cc.AudioEngine.getInstance().playEffect(s_shipDestroyEffect);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
hurt:function () {
|
|
||||||
if (this.canBeAttack) {
|
|
||||||
this._hurtColorLife = 2;
|
|
||||||
this.HP--;
|
|
||||||
this.setColor(cc.RED);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
collideRect:function(){
|
|
||||||
var p = this.getPosition();
|
|
||||||
var a = this.getContentSize();
|
|
||||||
var r = new cc.rect(p.x - a.width/2, p.y - a.height/2, a.width, a.height/2);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,110 +0,0 @@
|
||||||
cc.dumpConfig();
|
|
||||||
|
|
||||||
var SysMenu = cc.Layer.extend({
|
|
||||||
_ship:null,
|
|
||||||
|
|
||||||
ctor:function () {
|
|
||||||
cc.associateWithNative( this, cc.Layer );
|
|
||||||
},
|
|
||||||
init:function () {
|
|
||||||
var bRet = false;
|
|
||||||
if (this._super()) {
|
|
||||||
winSize = cc.Director.getInstance().getWinSize();
|
|
||||||
var sp = cc.Sprite.create(s_loading);
|
|
||||||
sp.setAnchorPoint(cc.p(0,0));
|
|
||||||
this.addChild(sp, 0, 1);
|
|
||||||
|
|
||||||
var logo = cc.Sprite.create(s_logo);
|
|
||||||
logo.setAnchorPoint(cc.p(0, 0));
|
|
||||||
logo.setPosition(cc.p(0, 250));
|
|
||||||
this.addChild(logo, 10, 1);
|
|
||||||
|
|
||||||
var newGameNormal = cc.Sprite.create(s_menu, cc.rect(0, 0, 126, 33));
|
|
||||||
var newGameSelected = cc.Sprite.create(s_menu, cc.rect(0, 33, 126, 33));
|
|
||||||
var newGameDisabled = cc.Sprite.create(s_menu, cc.rect(0, 33 * 2, 126, 33));
|
|
||||||
|
|
||||||
var gameSettingsNormal = cc.Sprite.create(s_menu, cc.rect(126, 0, 126, 33));
|
|
||||||
var gameSettingsSelected = cc.Sprite.create(s_menu, cc.rect(126, 33, 126, 33));
|
|
||||||
var gameSettingsDisabled = cc.Sprite.create(s_menu, cc.rect(126, 33 * 2, 126, 33));
|
|
||||||
|
|
||||||
var aboutNormal = cc.Sprite.create(s_menu, cc.rect(252, 0, 126, 33));
|
|
||||||
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));
|
|
||||||
|
|
||||||
var newGame = cc.MenuItemSprite.create(newGameNormal, newGameSelected, newGameDisabled, this, function () {
|
|
||||||
this.onButtonEffect();
|
|
||||||
flareEffect(this, this, this.onNewGame);
|
|
||||||
});
|
|
||||||
var gameSettings = cc.MenuItemSprite.create(gameSettingsNormal, gameSettingsSelected, gameSettingsDisabled, this, this.onSettings);
|
|
||||||
var about = cc.MenuItemSprite.create(aboutNormal, aboutSelected, aboutDisabled, this, this.onAbout);
|
|
||||||
|
|
||||||
var menu = cc.Menu.create(newGame, gameSettings, about);
|
|
||||||
menu.alignItemsVerticallyWithPadding(10);
|
|
||||||
this.addChild(menu, 1, 2);
|
|
||||||
menu.setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 80));
|
|
||||||
this.schedule(this.update, 0.1);
|
|
||||||
|
|
||||||
var tmp = cc.TextureCache.getInstance().addImage(s_ship01);
|
|
||||||
this._ship = cc.Sprite.createWithTexture(tmp,cc.rect(0, 45, 60, 38));
|
|
||||||
this.addChild(this._ship, 0, 4);
|
|
||||||
var pos = cc.p(Math.random() * winSize.width, 0);
|
|
||||||
this._ship.setPosition( pos );
|
|
||||||
this._ship.runAction(cc.MoveBy.create(2, cc.p(Math.random() * winSize.width, pos.y + winSize.height + 100)));
|
|
||||||
|
|
||||||
if (MW.SOUND) {
|
|
||||||
cc.AudioEngine.getInstance().setBackgroundMusicVolume(0.7);
|
|
||||||
cc.AudioEngine.getInstance().playBackgroundMusic(s_mainMainMusic, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bRet = true;
|
|
||||||
}
|
|
||||||
return bRet;
|
|
||||||
},
|
|
||||||
onNewGame:function (pSender) {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
scene.addChild(GameLayer.create());
|
|
||||||
scene.addChild(GameControlMenu.create());
|
|
||||||
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2, scene));
|
|
||||||
},
|
|
||||||
onSettings:function (pSender) {
|
|
||||||
this.onButtonEffect();
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
scene.addChild(SettingsLayer.create());
|
|
||||||
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2, scene));
|
|
||||||
},
|
|
||||||
onAbout:function (pSender) {
|
|
||||||
this.onButtonEffect();
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
scene.addChild(AboutLayer.create());
|
|
||||||
cc.Director.getInstance().replaceScene(cc.TransitionFade.create(1.2, scene));
|
|
||||||
},
|
|
||||||
update:function () {
|
|
||||||
if (this._ship.getPosition().y > 480) {
|
|
||||||
var pos = cc.p(Math.random() * winSize.width, 10);
|
|
||||||
this._ship.setPosition( pos );
|
|
||||||
this._ship.runAction( cc.MoveBy.create(
|
|
||||||
parseInt(5 * Math.random(), 10),
|
|
||||||
cc.p(Math.random() * winSize.width, pos.y + 480)));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onButtonEffect:function(){
|
|
||||||
if (MW.SOUND) {
|
|
||||||
var s = cc.AudioEngine.getInstance().playEffect(s_buttonEffect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
SysMenu.create = function () {
|
|
||||||
var sg = new SysMenu();
|
|
||||||
if (sg && sg.init()) {
|
|
||||||
return sg;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
SysMenu.scene = function () {
|
|
||||||
var scene = cc.Scene.create();
|
|
||||||
var layer = SysMenu.create();
|
|
||||||
scene.addChild(layer);
|
|
||||||
return scene;
|
|
||||||
};
|
|
|
@ -1,56 +0,0 @@
|
||||||
var EnemyType = [
|
|
||||||
{
|
|
||||||
type:0,
|
|
||||||
textureName:"E0.png",
|
|
||||||
bulletType:"W2.png",
|
|
||||||
HP:1,
|
|
||||||
moveType:MW.ENEMY_MOVE_TYPE.ATTACK,
|
|
||||||
attackMode:MW.ENEMY_MOVE_TYPE.NORMAL,
|
|
||||||
scoreValue:15
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type:1,
|
|
||||||
textureName:"E1.png",
|
|
||||||
bulletType:"W2.png",
|
|
||||||
HP:2,
|
|
||||||
moveType:MW.ENEMY_MOVE_TYPE.ATTACK,
|
|
||||||
attackMode:MW.ENEMY_MOVE_TYPE.NORMAL,
|
|
||||||
scoreValue:40
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type:2,
|
|
||||||
textureName:"E2.png",
|
|
||||||
bulletType:"W2.png",
|
|
||||||
HP:4,
|
|
||||||
moveType:MW.ENEMY_MOVE_TYPE.HORIZONTAL,
|
|
||||||
attackMode:MW.ENEMY_ATTACK_MODE.TSUIHIKIDAN,
|
|
||||||
scoreValue:60
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type:3,
|
|
||||||
textureName:"E3.png",
|
|
||||||
bulletType:"W2.png",
|
|
||||||
HP:6,
|
|
||||||
moveType:MW.ENEMY_MOVE_TYPE.OVERLAP,
|
|
||||||
attackMode:MW.ENEMY_MOVE_TYPE.NORMAL,
|
|
||||||
scoreValue:80
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type:4,
|
|
||||||
textureName:"E4.png",
|
|
||||||
bulletType:"W2.png",
|
|
||||||
HP:10,
|
|
||||||
moveType:MW.ENEMY_MOVE_TYPE.HORIZONTAL,
|
|
||||||
attackMode:MW.ENEMY_ATTACK_MODE.TSUIHIKIDAN,
|
|
||||||
scoreValue:150
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type:5,
|
|
||||||
textureName:"E5.png",
|
|
||||||
bulletType:"W2.png",
|
|
||||||
HP:15,
|
|
||||||
moveType:MW.ENEMY_MOVE_TYPE.HORIZONTAL,
|
|
||||||
attackMode:MW.ENEMY_MOVE_TYPE.NORMAL,
|
|
||||||
scoreValue:200
|
|
||||||
}
|
|
||||||
];
|
|
|
@ -1,94 +0,0 @@
|
||||||
/**
|
|
||||||
* Cocos2d-html5 show case : Moon Warriors
|
|
||||||
*
|
|
||||||
* @Licensed:
|
|
||||||
* This showcase is licensed under GPL.
|
|
||||||
*
|
|
||||||
* @Authors:
|
|
||||||
* Programmer: Shengxiang Chen (陈升想), Dingping Lv (吕定平), Ricardo Quesada
|
|
||||||
* Effects animation: Hao Wu (吴昊)
|
|
||||||
* Quality Assurance: Sean Lin (林顺)
|
|
||||||
*
|
|
||||||
* @Links:
|
|
||||||
* http://www.cocos2d-x.org
|
|
||||||
* http://bbs.html5china.com
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
//game state
|
|
||||||
MW.GAME_STATE = {
|
|
||||||
HOME:0,
|
|
||||||
PLAY:1,
|
|
||||||
OVER:2
|
|
||||||
};
|
|
||||||
|
|
||||||
//keys
|
|
||||||
MW.KEYS = [];
|
|
||||||
|
|
||||||
//level
|
|
||||||
MW.LEVEL = {
|
|
||||||
STAGE1:1,
|
|
||||||
STAGE2:2,
|
|
||||||
STAGE3:3
|
|
||||||
};
|
|
||||||
|
|
||||||
//life
|
|
||||||
MW.LIFE = 4;
|
|
||||||
|
|
||||||
//score
|
|
||||||
MW.SCORE = 0;
|
|
||||||
|
|
||||||
//sound
|
|
||||||
MW.SOUND = true;
|
|
||||||
|
|
||||||
//enemy move type
|
|
||||||
MW.ENEMY_MOVE_TYPE = {
|
|
||||||
ATTACK:0,
|
|
||||||
VERTICAL:1,
|
|
||||||
HORIZONTAL:2,
|
|
||||||
OVERLAP:3
|
|
||||||
};
|
|
||||||
|
|
||||||
//delta x
|
|
||||||
MW.DELTA_X = -100;
|
|
||||||
|
|
||||||
//offset x
|
|
||||||
MW.OFFSET_X = -24;
|
|
||||||
|
|
||||||
//rot
|
|
||||||
MW.ROT = -5.625;
|
|
||||||
|
|
||||||
//bullet type
|
|
||||||
MW.BULLET_TYPE = {
|
|
||||||
PLAYER:1,
|
|
||||||
ENEMY:2
|
|
||||||
};
|
|
||||||
|
|
||||||
//weapon type
|
|
||||||
MW.WEAPON_TYPE = {
|
|
||||||
ONE:1
|
|
||||||
};
|
|
||||||
|
|
||||||
//unit tag
|
|
||||||
MW.UNIT_TAG = {
|
|
||||||
ENMEY_BULLET:900,
|
|
||||||
PLAYER_BULLET:901,
|
|
||||||
ENEMY:1000,
|
|
||||||
PLAYER:1000
|
|
||||||
};
|
|
||||||
|
|
||||||
//attack mode
|
|
||||||
MW.ENEMY_ATTACK_MODE = {
|
|
||||||
NORMAL:1,
|
|
||||||
TSUIHIKIDAN:2
|
|
||||||
};
|
|
||||||
|
|
||||||
//life up sorce
|
|
||||||
MW.LIFEUP_SORCE = [50000, 100000, 150000, 200000, 250000, 300000];
|
|
||||||
|
|
||||||
//container
|
|
||||||
MW.CONTAINER = {
|
|
||||||
ENEMIES:[],
|
|
||||||
ENEMY_BULLETS:[],
|
|
||||||
PLAYER_BULLETS:[]
|
|
||||||
};
|
|
|
@ -1,49 +0,0 @@
|
||||||
var Level1 = {
|
|
||||||
enemies:[
|
|
||||||
{
|
|
||||||
ShowType:"Repeate",
|
|
||||||
ShowTime:"00:02",
|
|
||||||
Types:[0,1,2]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ShowType:"Repeate",
|
|
||||||
ShowTime:"00:05",
|
|
||||||
Types:[3,4,5]
|
|
||||||
}
|
|
||||||
/*{
|
|
||||||
ShowType:"Repeate",
|
|
||||||
ShowTime:"00:08",
|
|
||||||
Types:[0,4,3,5]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ShowType:"Once",
|
|
||||||
ShowTime:"00:6",
|
|
||||||
Types:[0,2,4,3]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ShowType:"Once",
|
|
||||||
ShowTime:"00:16",
|
|
||||||
Types:[0,2,5,4,3]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ShowType:"Once",
|
|
||||||
ShowTime:"00:25",
|
|
||||||
Types:[0,3,5,4,3]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ShowType:"Once",
|
|
||||||
ShowTime:"00:35",
|
|
||||||
Types:[4,5,3,1,3]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ShowType:"Once",
|
|
||||||
ShowTime:"00:50",
|
|
||||||
Types:[0,3,2,1,0,3]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ShowType:"Once",
|
|
||||||
ShowTime:"01:15",
|
|
||||||
Types:[4,5,2,1,0]
|
|
||||||
}*/
|
|
||||||
]
|
|
||||||
};
|
|
Loading…
Reference in New Issue