You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
859 B
37 lines
859 B
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class TouchScaleScript extends cc.Component {
|
|
|
|
@property({
|
|
type: cc.Node,
|
|
displayName: '触发节点'
|
|
})
|
|
scaleNode: cc.Node = null
|
|
|
|
@property(cc.Float)
|
|
scaleTimes: number = 1.1;
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad () {
|
|
if (!this.scaleNode) {
|
|
this.scaleNode = this.node
|
|
}
|
|
this.openTouchEvent(this.node)
|
|
}
|
|
|
|
openTouchEvent(node) {
|
|
node.on(cc.Node.EventType.TOUCH_START, this.touchStartNode, this)
|
|
node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndNode, this)
|
|
node.on(cc.Node.EventType.TOUCH_END, this.touchEndNode, this)
|
|
}
|
|
touchStartNode(event) {
|
|
this.scaleNode.scale = this.scaleTimes
|
|
}
|
|
touchEndNode(event) {
|
|
this.scaleNode.scale = 1
|
|
}
|
|
}
|
|
|