Skip to content

Commit

Permalink
Merge branch 'master' of github.com:iTyran/SK_CardGame
Browse files Browse the repository at this point in the history
  • Loading branch information
gloryming committed Sep 16, 2013
2 parents 233ced2 + 15d67ef commit 6ea6b15
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
4 changes: 2 additions & 2 deletions projects/CardGame/Resources/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var Animal = cc.Class.extend({
this._animate.setFlipX(true);
this._animate.setPosition(cc.pAdd(this._center, cc.p(30, 0)));
this._layer.addChild(this._animate);
this._animate.runAction(Utile.getAnimate(0.1, IMG.attack, this.unAnimate, this));
this._animate.runAction(Utile.getAnimate(0.08, IMG.attack, this.unAnimate, this));
// this._animate.runAction(Utile.getAnimate(0.1, IMG.attack));
}else{
this.unAnimate();
Expand All @@ -43,7 +43,7 @@ var Animal = cc.Class.extend({
this._animate = cc.Sprite.create(IMG.hurt[0]);
this._animate.setPosition(cc.pAdd(this._center, cc.p(0, 0)));
this._layer.addChild(this._animate);
this._animate.runAction(Utile.getAnimate(0.12, IMG.hurt, this.unAnimate, this));
this._animate.runAction(Utile.getAnimate(0.10, IMG.hurt, this.unAnimate, this));
// this._animate.runAction(Utile.getAnimate(0.15, IMG.hurt));

// damage label
Expand Down
8 changes: 7 additions & 1 deletion projects/CardGame/Resources/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ var VisibleRect = {
};

var ModeLayer = cc.Layer.extend({
_delegate: null,
init:function(delegate){
this._delegate = delegate;
},
onEnter:function(){
cc.registerTargettedDelegate(cc.MENU_HANDLER_PRIORITY, true, this);
this._super();
Expand All @@ -406,7 +410,9 @@ var ModeLayer = cc.Layer.extend({
return true;
},
onTouchEnded:function(){
cc.log("touch action");
// cc.log("touch action");
if (this._delegate)
this._delegate.modelLayerTouch();
}
});

Expand Down
33 changes: 27 additions & 6 deletions projects/CardGame/Resources/Fight.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ var FightLayer = cc.Layer.extend({
// var json = cc.FileUtils.getInstance().getStringFromFile("json/combat.json");
this._combat = combat;
this.startCombat();

this.initDisplay();

this.combatEnd();

return true;
}
return false;
Expand Down Expand Up @@ -80,9 +77,31 @@ var FightLayer = cc.Layer.extend({
combatEnd:function(){
var end = this._combat.End;
cc.log("action end;");
// var ml = new ModeLayer();
// ml.init();
// this.addChild(ml);

// add combat result layer

var ml = new ModeLayer();
ml.init();
ml.init(this);

var endLayer = cc.LayerColor.create(cc.c4b(0, 0, 0, 192), VisibleRect.rect().width, VisibleRect.rect().height);
endLayer.setPosition(cc.p(0, 0));
ml.addChild(endLayer);
this.addChild(ml);

var lblExperience = cc.LabelTTF.create("Experience: " + this._combat.End.Experience, "", 66);
cc.log("result:" + this._combat.End.Result);
var lblisWin = cc.LabelTTF.create(this._combat.End.Result ? "You Win !": "You Lost !", "", 66);
lblExperience.setPosition(cc.pAdd(VisibleRect.center(), cc.p(0, 100)));
lblisWin.setPosition(cc.pAdd(VisibleRect.center(), cc.p(0, -100)));
endLayer.addChild(lblExperience);
endLayer.addChild(lblisWin);
},
modelLayerTouch:function(){
// cc.log("action mode layer touch ");
cc.Director.getInstance().replaceScene(InstanceLayer.scene());
},
getCardByHash:function(hash){
for(var mi in this._my){
Expand All @@ -104,10 +123,12 @@ var FightLayer = cc.Layer.extend({
this._nFight.setAnchorPoint(cc.p(0.5 ,0));

this._animalNode = cc.Node.create();
this._animalNode.setPosition(cc.p(cs.width / 2, cs.height / 2));

var p = cc.pSub(VisibleRect.topRight(), cc.p(cs.width, cs.height));
this.setPosition(cc.p(p.x / 2, p.y / 2));
// this.setPosition(cc.p(p.x / 2, p.y / 2));
this._nFight.setPosition(cc.p(p.x / 2, p.y / 2));
this._animalNode.setPosition(cc.pAdd(cc.p(cs.width / 2, cs.height / 2), cc.p(p.x / 2, p.y / 2)));

this.addChild(this._nFight);
this.addChild(this._animalNode);

Expand Down
1 change: 1 addition & 0 deletions projects/CardGame/Resources/Instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var InstanceLayer = cc.Layer.extend({
menu.setPosition(cc.p(0, 0));
this.addChild(menu);


},
initMenu:function(){

Expand Down
3 changes: 2 additions & 1 deletion projects/CardGame/Resources/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ require("Utile.js");

try{
// var uri = "172.100.104.204:1234";
var uri = "172.100.104.192:1234";
// var uri = "172.100.104.192:1234";
var uri = "115.28.12.75:1234";
// var uri = "ws://localhost:8082/echo;
Socket.getInstance().setUri(uri);
director = cc.Director.getInstance();
Expand Down

0 comments on commit 6ea6b15

Please sign in to comment.