一个按钮缩放的效果,这种绑定到按钮不生效,求解。单独‘touchstart’事件是可以。
`
cc.Class({
extends: cc.Component,
properties: {
pressScale:0.8,
duration:0
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
let initScale = this.node.scale;
let animationScaleDown = cc.scaleTo(this.duration, this.pressScale);
let animationScaleUp = cc.scaleTo(this.duration, initScale);
function onTouchDown(event)
{
console.log("down");
this.stopAllActions();
this.runAction(animationScaleDown);
}
function onTouchUp(event)
{
console.log(initScale);
this.stopAllActions();
this.runAction(animationScaleUp);
}
this.node.on('touchstart', onTouchDown, this.node);
this.node.on('touchend', onTouchUp, this.node);
this.node.on('touchcancel', onTouchUp, this.node);
},
start () {
},
// update (dt) {},
});
`