1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import tween = cc.tween;
- const {ccclass, property} = cc._decorator;
- /**
- * 指引
- */
- @ccclass
- export default class UiGuideHand extends cc.Component {
- @property(cc.SpriteFrame)
- handSpriteFrames: cc.SpriteFrame [] = [];
- @property(cc.Node)
- cycleNode: cc.Node = null;
- @property(cc.Node)
- maskNode: cc.Node = null;
- @property(cc.Sprite)
- handSprite: cc.Sprite = null;
- cycleTime = 0.5;
- handTime = 0.5;
- onLoad() {
- tween(this.handSprite.node)
- .repeatForever(tween(this.handSprite.node)
- .call(() => {
- this.cycleNode.opacity = 255;
- this.cycleNode.scale = 0.2;
- tween(this.cycleNode)
- .to(0.8,{scale:2,opacity:0})
- .start();
- this.handSprite.spriteFrame = this.handSpriteFrames[1]
- })
- .delay(this.handTime)
- .call(() => {
- this.handSprite.spriteFrame = this.handSpriteFrames[0];
- })
- .delay(this.handTime)
- .start())
- .start();
- }
- init(node:cc.Node){
- this.node.position = node.position;
- }
- onEnable() {
- this.maskNode.on('touchstart', this.onTouchStart, this);
- }
- onDestroy() {
- this.maskNode.off('touchstart', this.onTouchStart, this);
- }
- clickSelf(){
- this.node.destroy();
- }
- onTouchStart(event:Event){
- this.node.destroy();
- //抛出事件
- //@ts-ignore
- this.maskNode._touchListener.setSwallowTouches(false);
- }
- }
|