|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, Component, EventTouch, instantiate, JsonAsset, Label, Layout, Node, Prefab, ScrollView, Sprite, sys, UITransform, Vec2, Vec3 } from 'cc';
|
|
|
+import { _decorator, Component, EventTouch, instantiate, JsonAsset, Label, Layout, Node, Prefab, ScrollView, Size, Sprite, sys, UITransform, Vec2, Vec3 } from 'cc';
|
|
|
import { http } from '../../http';
|
|
|
import { gameManager } from '../gameManager';
|
|
|
import { LevelInfoMessage, LevelItemData, LevelMessage, scene_item_data } from '../../../data/data';
|
|
@@ -74,12 +74,13 @@ export class game_list extends Component {
|
|
|
|
|
|
let layout = this.content.getComponent(Layout)
|
|
|
let item = instantiate(this.game_level_item)
|
|
|
- let widget_height = (item.getComponent(UITransform).height*3 + layout.spacingY*2)
|
|
|
- let padding_top = (this.content.getComponent(UITransform).height - widget_height) / 2
|
|
|
- layout.paddingTop = padding_top
|
|
|
+ let widget_height = item.getComponent(UITransform).height*3
|
|
|
+ let padding_y = (this.content.getComponent(UITransform).height - widget_height) / 4
|
|
|
+ layout.paddingTop = padding_y
|
|
|
+ layout.spacingY = padding_y
|
|
|
|
|
|
let item_spacing_x = (this.content.getComponent(UITransform).width - item.getComponent(UITransform).width*2) / 3
|
|
|
- layout.paddingLeft = item_spacing_x - 20
|
|
|
+ layout.paddingLeft = item_spacing_x
|
|
|
layout.spacingX = item_spacing_x
|
|
|
}
|
|
|
|
|
@@ -105,38 +106,7 @@ export class game_list extends Component {
|
|
|
this.start_pos = et.getUILocation()
|
|
|
})
|
|
|
this.content.on(Node.EventType.TOUCH_MOVE,(et:EventTouch)=>{
|
|
|
- // console.log('select_page=',gameManager.getStaticUserData().select_page)
|
|
|
- // if(gameManager.getStaticUserData().select_page ==1) {
|
|
|
- // return
|
|
|
- // }
|
|
|
- this.onTouchActive = false
|
|
|
- if( Math.abs(this.start_pos.x-et.getUILocation().x)<30){
|
|
|
- this.start_pos = et.getUILocation()
|
|
|
- this.onTouchActive = true
|
|
|
- return
|
|
|
- }
|
|
|
- let p = new Vec3(et.getUILocation().x,et.getUILocation().y)
|
|
|
- let n_p = this.content.parent.getComponent(UITransform).convertToNodeSpaceAR(p)
|
|
|
- let pos = this.content.parent.getComponent(UITransform).convertToWorldSpaceAR(this.content.position)
|
|
|
- if(this.x_len==0){
|
|
|
- this.x_len = (et.getUILocation().x - pos.x)*1;
|
|
|
- }
|
|
|
- let content_position_x = n_p.x-this.x_len
|
|
|
- console.log('content_position_x=',content_position_x)
|
|
|
- this.content.position = new Vec3(content_position_x,this.content.position.y);
|
|
|
- // this.onTouchActive = false
|
|
|
- // if( Math.abs(this.start_pos.x-et.getUILocation().x)<30){
|
|
|
- // this.start_pos = et.getUILocation()
|
|
|
- // this.onTouchActive = true
|
|
|
- // return
|
|
|
- // }
|
|
|
- // let p = new Vec3(et.getUILocation().x,et.getUILocation().y)
|
|
|
- // let n_p = this.content.parent.getComponent(UITransform).convertToNodeSpaceAR(p)
|
|
|
- // let pos = this.content.parent.getComponent(UITransform).convertToWorldSpaceAR(this.content.position)
|
|
|
- // if(this.x_len==0){
|
|
|
- // this.x_len = (et.getUILocation().x - pos.x)*1;
|
|
|
- // }
|
|
|
- // this.content.position = new Vec3(n_p.x-this.x_len ,this.content.position.y);
|
|
|
+ this.touchContentMove(et)
|
|
|
})
|
|
|
this.content.on(Node.EventType.TOUCH_END,()=>{
|
|
|
this.x_len = 0
|
|
@@ -150,10 +120,43 @@ export class game_list extends Component {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ touchContentMove(et:EventTouch) {
|
|
|
+ this.onTouchActive = false
|
|
|
+ let p = new Vec3(et.getUILocation().x,et.getUILocation().y)
|
|
|
+ let n_p = this.content.parent.getComponent(UITransform).convertToNodeSpaceAR(p)
|
|
|
+ let pos = this.content.parent.getComponent(UITransform).convertToWorldSpaceAR(this.content.position)
|
|
|
+ if(this.x_len==0){
|
|
|
+ this.x_len = (et.getUILocation().x - pos.x)*1;
|
|
|
+ }
|
|
|
+ let content_position_x = n_p.x-this.x_len
|
|
|
+ // console.log('content_position_x=',content_position_x)
|
|
|
+ let select_page = gameManager.getStaticUserData().select_page
|
|
|
+ if(select_page==1 && content_position_x > this.content_original_pos.x - 50) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(select_page==this.getAllPage() && content_position_x < this.content_original_pos.x + 50) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.content.position = new Vec3(content_position_x,this.content.position.y);
|
|
|
+
|
|
|
+ // this.onTouchActive = false
|
|
|
+ // if( Math.abs(this.start_pos.x-et.getUILocation().x)<30){
|
|
|
+ // this.start_pos = et.getUILocation()
|
|
|
+ // this.onTouchActive = true
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // let p = new Vec3(et.getUILocation().x,et.getUILocation().y)
|
|
|
+ // let n_p = this.content.parent.getComponent(UITransform).convertToNodeSpaceAR(p)
|
|
|
+ // let pos = this.content.parent.getComponent(UITransform).convertToWorldSpaceAR(this.content.position)
|
|
|
+ // if(this.x_len==0){
|
|
|
+ // this.x_len = (et.getUILocation().x - pos.x)*1;
|
|
|
+ // }
|
|
|
+ // this.content.position = new Vec3(n_p.x-this.x_len ,this.content.position.y);
|
|
|
+ }
|
|
|
+
|
|
|
touchContentScroll() {
|
|
|
this.onTouchActive = true
|
|
|
if(this.content.position.x==this.content_original_pos.x) {
|
|
|
- console.log('touchContentScroll touchContentScroll')
|
|
|
return
|
|
|
}
|
|
|
if(this.content.position.x < 0) { // 向左滑动
|