123456789101112131415161718192021222324252627282930313233343536373839404142 |
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class RandomPut extends cc.Component {
- @property
- private isDirection: boolean = false;
- @property
- private isAngle: boolean = false;
- @property
- private isFanzhuan: boolean = false;
- // LIFE-CYCLE CALLBACKS:
- onEnable() {
-
- }
- start() {
- let left = (Math.random() > 0.5) ? true : false;
- if (this.isDirection) {
- let posX = Math.abs(this.node.x);
- this.node.x = (left) ? posX : -posX;
- let angles = Math.abs(this.node.angle);
- this.node.angle = (left) ? angles : -angles;
- console.log('isDirection:', this.node.x, left, ' this.node.angle', this.node.angle);
- }
- if (this.isAngle) {
- let angle = Math.abs(this.node.angle);
- this.node.angle = (left) ? angle : -angle;
- }
- if (this.isFanzhuan) {
- let scaleX = Math.abs(this.node.scaleX);
- this.node.scaleX = (left) ? scaleX : -scaleX;
- }
- }
- // update (dt) {}
- }
|