mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
57
JisolGameCocos/assets/script/ui/Home/Control/MainControl.ts
Normal file
57
JisolGameCocos/assets/script/ui/Home/Control/MainControl.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "00caacaa-5016-4f56-8ff0-a6ebeb991e96",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user