cocos2d-js 카드 뒤집기
20370 단어 Cocos2d-JS
pg.TurnCardLayer = cc.Layer.extend({
okBtn: null
});
pg.TurnCardLayer.create = function () {
var res = new pg.TurnCardLayer();
return (res && res.init()) ? res : null;
};
pg.TurnCardLayer.prototype.ctor = function () {
cc.Layer.prototype.ctor.call(this);
//
console.log("TurnCardLayer:init");
//
var winSize = cc.winSize;
//
pg.setDefaultTextureFormat(cc.Texture2D.PIXEL_FORMAT_RGB565);
//
var bgSprite = new cc.Sprite(res.StartBG_568_png);
bgSprite.setPosition(winSize.width / 2, winSize.height / 2);
this.addChild(bgSprite);
//
pg.setDefaultTextureFormat(cc.Texture2D.PIXEL_FORMAT_RGBA4444);
var okBtnItem = cc.MenuItemImage.create(res.Start_png);
okBtnItem.setPosition(winSize.width / 2, winSize.height / 2);
var menu = new cc.Menu(okBtnItem);
menu.setPosition(0, 0);
this.addChild(menu, 10);
//
pg.dumpTextureInfo();
};
pg.TurnCardLayer.prototype.init = function () {
return true;
};
pg.TurnCardLayer.prototype.onClear = function () {
pg.Layer.prototype.onClear();
console.log("TurnCardLayer:clear");
pg.removeTextureForKey(res.StartBG_568_png);
};
pg.TurnCardScene = cc.Scene.extend({
actionIsDone: false
});
pg.TurnCardScene.create = function (num) {
var res = new pg.TurnCardScene();
if (res && res.init(num)) {
// var layer = pg.TurnCardLayer.create();
// res.addChild(layer);
return res;
}
return null;
};
pg.TurnCardScene.prototype.init = function (num) {
//
// var background = cc.LayerColor.create(cc.color(255, 180, 255, 255), cc.size.width, cc.size.height);
// this.addChild(background);
this.actionIsDone = true;//
this.createPoker(); //
this.createListener(); //
return true;
};
//
pg.TurnCardScene.prototype.createPoker = function () {
//
//
// var pokerFront = new cc.Sprite(res.Card_Clubs_2_png);
// pokerFront.setVisible(true);
// pokerFront.setPosition(cc.p(cc.winSize.width / 2, cc.winSize.height / 2));
// this.addChild(pokerFront, 1, 123);
//
//
var pokerBack = new cc.Sprite(res.Card_BackGround_Normal_png);
pokerBack.setPosition(cc.p(cc.winSize.width / 2, cc.winSize.height / 2));
this.addChild(pokerBack, 1, 321);
};
//
pg.TurnCardScene.prototype.startOrbitAction = function () {
// //
// var pokerFront = this.getChildByTag(123);
// //
var pokerBack = this.getChildByTag(321);
var actionBy = cc.rotateBy(0.2, 0, -90);
pokerBack.runAction(cc.sequence(actionBy,
cc.callFunc( function() {
pokerBack.setTexture(res.Card_Clubs_2_png);
pokerBack.setFlippedX(true);
}),
actionBy
));
};
pg.TurnCardScene.prototype.actionIsDownFunc = function () {
this.actionIsDone = true;
};
pg.TurnCardScene.prototype.createListener = function() {
var listener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ALL_AT_ONCE,
swallowTouches: true,
onTouchesBegan: function (touches, event) {
var target = event.getCurrentTarget();
target.onTouchBegan(touches);
return true;
},
onTouchesMoved: function (touches, event) {
var target = event.getCurrentTarget();
target.onTouchMoved(touches);
},
onTouchesEnded: function (touches, event) {
var target = event.getCurrentTarget();
target.onTouchEnded(touches);
}
});
cc.eventManager.addListener(listener, this);
};
pg.TurnCardScene.prototype.onTouchBegan = function (touches) {
var touch = touches[0];
var convertedLocation = touch.getLocation();
this.startOrbitAction();
return true;
};
pg.TurnCardScene.prototype.onTouchMoved = function (touches) {
var touch = touches[0];
var convertedLocation = touch.getLocation();
};
pg.TurnCardScene.prototype.onTouchEnded = function (touches) {
};
pg.TurnCardScene.prototype.onEnter = function () {
cc.Layer.prototype.onEnter.call(this);
};
pg.TurnCardScene.prototype.onExit = function (){
cc.Layer.prototype.onExit.call(this);
};
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
cocos2d-js 카드 뒤집기pg.TurnCardLayer = cc.Layer.extend({ okBtn: null }); pg.TurnCardLayer.create = function () { var res = new pg.TurnCardLa...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.