|
@@ -5,26 +5,29 @@ const { ccclass, property } = _decorator;
|
|
|
@ccclass('weiqi_item')
|
|
|
export class weiqi_item extends Component {
|
|
|
private mDur:number = 0
|
|
|
+ private old_pos:Vec3 = null
|
|
|
public init(){
|
|
|
this.hide()
|
|
|
}
|
|
|
public play(duration: number){
|
|
|
this.mDur = duration
|
|
|
+
|
|
|
if(this.node.parent!=null){
|
|
|
- // let dir = this.node.parent.getComponent(weiqi_manager).getDir()
|
|
|
- this.node.position = this.node.parent.getComponent(weiqi_manager).getOriginPos()
|
|
|
- // let nor = pos.subtract(dir).normalize()
|
|
|
- // let ndir = nor.multiplyScalar(dis)
|
|
|
- this.show()
|
|
|
- tween(this.node).delay(duration).call(()=>{
|
|
|
- this.hide()
|
|
|
- this.play(this.mDur)
|
|
|
- })
|
|
|
- // .to(duration,{position:dir}).call(()=>{
|
|
|
- // this.hide()
|
|
|
- // this.play(this.mDur)
|
|
|
- // })
|
|
|
- .start()
|
|
|
+ // let dir = this.node.parent.getComponent(weiqi_manager).getDir()
|
|
|
+ this.old_pos =this.node.parent.getComponent(weiqi_manager).getOriginPos()
|
|
|
+ this.node.position = new Vec3(this.old_pos.x,this.old_pos.y)
|
|
|
+ // let nor = pos.subtract(dir).normalize()
|
|
|
+ // let ndir = nor.multiplyScalar(dis)
|
|
|
+ tween(this.node).delay(duration).call(()=>{
|
|
|
+ this.show()
|
|
|
+ this.old_pos=null
|
|
|
+ this.play(this.mDur)
|
|
|
+ })
|
|
|
+ // .to(duration,{position:dir}).call(()=>{
|
|
|
+ // this.hide()
|
|
|
+ // this.play(this.mDur)
|
|
|
+ // })
|
|
|
+ .start()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -41,7 +44,13 @@ export class weiqi_item extends Component {
|
|
|
}
|
|
|
|
|
|
protected update(dt: number): void {
|
|
|
- this.node.position = new Vec3(this.node.position.x,this.node.position.y-dt*200)
|
|
|
+ if(this.old_pos!=null){
|
|
|
+ this.node.position = new Vec3(this.node.position.x,this.node.position.y-dt*200)
|
|
|
+ if(Vec3.distance(this.node.position,this.old_pos)>150){
|
|
|
+ this.hide()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|