Commit b0fb585a authored by Đặng Minh Chiến's avatar Đặng Minh Chiến

UILevel

parent a926be3b
This diff is collapsed.
// Learn TypeScript:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
import LocalStorage from "../../../Data/LocalStorage";
const { ccclass, property } = cc._decorator;
......@@ -27,7 +20,6 @@ export default class ItemLevel extends cc.Component {
this.level = level - 1;
this.txtLevel.string = level + "";
this.setup(LocalStorage.getLevel());
this.node.on(cc.Node.EventType.TOUCH_END, this.onClickLevel, this);
}
setup(curentLevel){
......@@ -57,5 +49,4 @@ export default class ItemLevel extends cc.Component {
console.log(this.level);
}
}
......@@ -21,28 +21,24 @@ export default class LevelScreen extends ScreenUI {
@property(cc.Node)
containerNodePage: cc.Node = null;
@property(cc.Node)
levelPage: cc.Node = null;
totalLevels: number = 0;
levelPerPage: number = 12;
curentLevel: number = 0;
totalPages: number = 0;
currentPage: number = 0;
targetPos: cc.Vec3 = new cc.Vec3(0, 0, 0);
@property(cc.Vec3)
pageStep: cc.Vec3 = new cc.Vec3(850, 0, 0);
tweenTime: number = 0.5;
pointStart: cc.Vec3 = null;
pointEnd: cc.Vec3 = null;
isMove: boolean = true;
listNodePage: NodePage[] = []
listPage: Page[] = []
isActive: boolean = false;
isMove: boolean = true;
override initialize(uiManager: UIManager): void {
super.initialize(uiManager);
......@@ -81,7 +77,7 @@ export default class LevelScreen extends ScreenUI {
if (this.currentPage < this.totalPages) {
this.currentPage++;
this.targetPos = cc.v3(this.targetPos.x + this.pageStep.x, this.targetPos.y + this.pageStep.y);
this.movePage();
this.movePage(this.targetPos);
this.updateNodePage(true);
}
}
......@@ -93,15 +89,15 @@ export default class LevelScreen extends ScreenUI {
if (this.currentPage > 0) {
this.currentPage--;
this.targetPos = cc.v3(this.targetPos.x - this.pageStep.x, this.targetPos.y - this.pageStep.y);
this.movePage();
this.movePage(this.targetPos);
this.updateNodePage(false);
}
}
}
movePage() {
movePage(targetPos ) {
cc.tween(this.containerPage)
.to(this.tweenTime, { position: this.targetPos }, { easing: "quintOut" })
.to(this.tweenTime, { position: targetPos }, { easing: "quintOut" })
.call(() => {
this.isMove = true;
})
......@@ -133,7 +129,7 @@ export default class LevelScreen extends ScreenUI {
super.active();
if (!this.isActive) {
this.isActive = true;
}else{
} else {
this.reloadNodePage();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment