| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /**
- * 预制类型
- */
- const { ccclass, property } = cc._decorator;
- import { JumpType } from '../game/enumConfig';
- @ccclass
- export default class jumpPrefab extends cc.Component {
- @property(cc.SpriteFrame)
- directionJump: cc.SpriteFrame = null;
- @property(cc.SpriteFrame)
- midJump: cc.SpriteFrame = null;
- @property(cc.SpriteFrame)
- rotateJump: cc.SpriteFrame = null;
- @property(cc.Sprite)
- showSprite: cc.Sprite = null;
- //当前跳的类型
- @property({ type: cc.Enum(JumpType) })
- currentJumpType: JumpType = JumpType.LEFT;
- bTrigger: Boolean = false;
- index: number = 0;
- // onLoad () {}
- start() {
- if (this.currentJumpType == JumpType.NORMAL) {
- this.showSprite.spriteFrame = this.midJump;
- } else if (this.currentJumpType == JumpType.LEFT) {
- this.showSprite.spriteFrame = this.directionJump;
- this.showSprite.node.scaleX = -1;
- } else if (this.currentJumpType == JumpType.RIGHT) {
- this.showSprite.spriteFrame = this.directionJump;
- } else if (this.currentJumpType == JumpType.LEFT_ROTATE) {
- this.showSprite.spriteFrame = this.rotateJump;
- } else if (this.currentJumpType == JumpType.RIGHT_ROTATE) {
- this.showSprite.spriteFrame = this.rotateJump;
- this.showSprite.node.scaleX = -1;
- }
- }
- setBTrigger() {
- this.bTrigger = !this.bTrigger;
- let _opacity = this.bTrigger ? 125 : 255;
- this.node.opacity = _opacity;
- }
- // update (dt) {}
- }
|