Commit 66c90dc3 authored by Friends233's avatar Friends233

fix兼容问题

parent b1a07f53
......@@ -127,7 +127,6 @@ export default class BlockManager extends cc.Component {
this.clearAllChildren()
this.checkBlockMatrix()
cc.find('Canvas').dispatchEvent(this.setBlockEvent)
// this.refreshMiniBlock()
return
}
......@@ -310,15 +309,20 @@ export default class BlockManager extends cc.Component {
const isRepeat = allTargetNodeId.find((_, i) => allTargetNodeId.includes(_, i + 1))
const GameScene = cc.find('Canvas').getComponent('GameScene')
// 新手引导情况下,只能放入对应位置
if(GameScene.isGuide && !isRepeat && isEmpty){
const {targetNode} = filterBlock?.[0]
if(allTargetNodeId[0] !== 90){
if (GameScene.isGuide && !isRepeat && isEmpty) {
const { targetNode } = filterBlock?.[0]
if (allTargetNodeId[0] !== 90) {
return false
}
}
return !isRepeat && isEmpty
}
nodeReset(){
this.node.setPosition(this.defaultPos)
this.node.scale = 1
}
addNodeEvent() {
this.node.on(cc.Node.EventType.TOUCH_START, () => {
if (this.isDisabled == 1) return
......@@ -327,15 +331,39 @@ export default class BlockManager extends cc.Component {
}, this)
this.node.on(cc.Node.EventType.TOUCH_END, () => {
this.setBlockMatrixAll()
if(this.isMove){
this.setBlockMatrixAll()
}
}, this)
this.node.on(cc.Node.EventType.TOUCH_MOVE, (e: cc.Event.EventTouch) => {
cc.find('Canvas').on(cc.Node.EventType.TOUCH_END,() => {
if(this.isMove){
this.setBlockMatrixAll()
}
})
cc.find('Canvas').on(cc.Node.EventType.TOUCH_CANCEL,() => {
if(this.isMove){
this.setBlockMatrixAll()
}
})
cc.find('Canvas').on(cc.Node.EventType.MOUSE_LEAVE,() => {
if(this.isMove){
this.setBlockMatrixAll()
}
})
this.node.on(cc.Node.EventType.TOUCH_MOVE, (e: cc.Event.EventTouch) => {
if (this.isMove) {
const pos: cc.Vec2 = e.getPreviousLocation()
const viewW = this.viewWidth, viewH = this.viewHeight
this.node.setPosition(pos.x - (viewW / 2), pos.y - (812 - (1624 - viewH) / 2)+Config.blockManagerDragOffsetY)
if (pos.x < 0 || pos.x > viewW || pos.y > (viewH - 200) || pos.y < 0) {
this.isMove = false
this.nodeReset()
return
}
this.node.setPosition(pos.x - (viewW / 2), pos.y - (812 - (1624 - viewH) / 2) + Config.blockManagerDragOffsetY)
}
}, this)
}
......
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