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"; import LocalStorage from "../../../Data/LocalStorage";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -27,7 +20,6 @@ export default class ItemLevel extends cc.Component { ...@@ -27,7 +20,6 @@ export default class ItemLevel extends cc.Component {
this.level = level - 1; this.level = level - 1;
this.txtLevel.string = level + ""; this.txtLevel.string = level + "";
this.setup(LocalStorage.getLevel()); this.setup(LocalStorage.getLevel());
this.node.on(cc.Node.EventType.TOUCH_END, this.onClickLevel, this);
} }
setup(curentLevel){ setup(curentLevel){
...@@ -57,5 +49,4 @@ export default class ItemLevel extends cc.Component { ...@@ -57,5 +49,4 @@ export default class ItemLevel extends cc.Component {
console.log(this.level); console.log(this.level);
} }
} }
...@@ -21,28 +21,24 @@ export default class LevelScreen extends ScreenUI { ...@@ -21,28 +21,24 @@ export default class LevelScreen extends ScreenUI {
@property(cc.Node) @property(cc.Node)
containerNodePage: cc.Node = null; containerNodePage: cc.Node = null;
@property(cc.Node)
levelPage: cc.Node = null;
totalLevels: number = 0; totalLevels: number = 0;
levelPerPage: number = 12; levelPerPage: number = 12;
curentLevel: number = 0; curentLevel: number = 0;
totalPages: number = 0; totalPages: number = 0;
currentPage: number = 0; currentPage: number = 0;
targetPos: cc.Vec3 = new cc.Vec3(0, 0, 0); targetPos: cc.Vec3 = new cc.Vec3(0, 0, 0);
@property(cc.Vec3) @property(cc.Vec3)
pageStep: cc.Vec3 = new cc.Vec3(850, 0, 0); pageStep: cc.Vec3 = new cc.Vec3(850, 0, 0);
tweenTime: number = 0.5; tweenTime: number = 0.5;
pointStart: cc.Vec3 = null;
pointEnd: cc.Vec3 = null;
isMove: boolean = true;
listNodePage: NodePage[] = [] listNodePage: NodePage[] = []
listPage: Page[] = [] listPage: Page[] = []
isActive: boolean = false; isActive: boolean = false;
isMove: boolean = true;
override initialize(uiManager: UIManager): void { override initialize(uiManager: UIManager): void {
super.initialize(uiManager); super.initialize(uiManager);
...@@ -81,7 +77,7 @@ export default class LevelScreen extends ScreenUI { ...@@ -81,7 +77,7 @@ export default class LevelScreen extends ScreenUI {
if (this.currentPage < this.totalPages) { if (this.currentPage < this.totalPages) {
this.currentPage++; this.currentPage++;
this.targetPos = cc.v3(this.targetPos.x + this.pageStep.x, this.targetPos.y + this.pageStep.y); 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); this.updateNodePage(true);
} }
} }
...@@ -93,15 +89,15 @@ export default class LevelScreen extends ScreenUI { ...@@ -93,15 +89,15 @@ export default class LevelScreen extends ScreenUI {
if (this.currentPage > 0) { if (this.currentPage > 0) {
this.currentPage--; this.currentPage--;
this.targetPos = cc.v3(this.targetPos.x - this.pageStep.x, this.targetPos.y - this.pageStep.y); 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); this.updateNodePage(false);
} }
} }
} }
movePage() { movePage(targetPos ) {
cc.tween(this.containerPage) cc.tween(this.containerPage)
.to(this.tweenTime, { position: this.targetPos }, { easing: "quintOut" }) .to(this.tweenTime, { position: targetPos }, { easing: "quintOut" })
.call(() => { .call(() => {
this.isMove = true; this.isMove = true;
}) })
...@@ -133,7 +129,7 @@ export default class LevelScreen extends ScreenUI { ...@@ -133,7 +129,7 @@ export default class LevelScreen extends ScreenUI {
super.active(); super.active();
if (!this.isActive) { if (!this.isActive) {
this.isActive = true; this.isActive = true;
}else{ } else {
this.reloadNodePage(); 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