mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import { _decorator, Component, Node } from 'cc';
|
|
import { JNPageView } from '../../../../../extensions/ngame/assets/ngame/util/components/pageview/JNPageView';
|
|
import { Button } from 'cc';
|
|
import { tween } from 'cc';
|
|
import { Widget } from 'cc';
|
|
import { UITransform } from 'cc';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('MainControl')
|
|
export class MainControl extends Component {
|
|
|
|
@property(Button)
|
|
leftButton:Button;
|
|
|
|
@property(Button)
|
|
rightButton:Button;
|
|
|
|
onLoad(){
|
|
this.onUpdateView();
|
|
}
|
|
|
|
onUpdateView(){
|
|
|
|
let pageIndex = this.getComponent(JNPageView).getCurrentPageIndex() - 1;
|
|
|
|
if(pageIndex){
|
|
tween(this.leftButton.getComponent(Widget))
|
|
.to(.3,{left:-this.leftButton.getComponent(UITransform).width})
|
|
.start();
|
|
tween(this.rightButton.getComponent(Widget))
|
|
.to(.3,{right:0})
|
|
.start();
|
|
}else{
|
|
tween(this.leftButton.getComponent(Widget))
|
|
.to(.3,{left:0})
|
|
.start();
|
|
tween(this.rightButton.getComponent(Widget))
|
|
.to(.3,{right:-this.rightButton.getComponent(UITransform).width})
|
|
.start();
|
|
}
|
|
|
|
}
|
|
|
|
//下一页
|
|
onClickRight(){
|
|
this.getComponent(JNPageView).setCurrentPageIndex(1);
|
|
this.onUpdateView();
|
|
}
|
|
//上一页
|
|
onClickLeft(){
|
|
this.getComponent(JNPageView).setCurrentPageIndex(0);
|
|
this.onUpdateView();
|
|
}
|
|
|
|
}
|
|
|
|
|