pubgv3/assets/scripts/game/newbieposarr.js
zhuguoqing ff550d5d6a init
2022-05-22 10:32:02 +08:00

66 lines
1.9 KiB
JavaScript

// Learn cc.Class:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
var jizhundy = 362
var jizhundx = 724
cc.Class({
extends: cc.Component,
properties: {
spritepoint:{
default: null,
type: cc.Node,
},
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
},
setdata(x,y){
this.ppos=cc.v2(x,y)
},
update (dt) {
var px = cc.gameMgr.watchPlayer.x
var py = cc.gameMgr.watchPlayer.y
var vw = cc.gameMgr.deltaX/cc.gameMgr.viewScale
var vh = cc.gameMgr.deltaY/cc.gameMgr.viewScale
var dxx = this.ppos.x-px
var dyy = this.ppos.y-py
if(Math.abs(dxx)<70&&Math.abs(dyy)<70){
this.node.active =false
return
}
if(Math.abs(dxx-dyy)>vh||Math.abs(dxx+dyy)>vw){
this.node.opacity = 255
}else{
this.node.opacity = 0
}
let pos1 = cc.gameMgr.ndplayer.convertToWorldSpaceAR(this.ppos);
let pos2 = this.node.parent.convertToNodeSpaceAR(pos1);
this.node.position = pos2
this.node.x = Math.max(Math.min(cc.winSize.width/2-15,this.node.x),-cc.winSize.width/2+15)
this.node.y = Math.max(Math.min(cc.winSize.height/2-15,this.node.y),-cc.winSize.height/2+15)
},
});