first commit
This commit is contained in:
43
assets/scripts/FruitNode.ts
Normal file
43
assets/scripts/FruitNode.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { _decorator, Component, Node, Vec3, EventTouch, tween } from "cc";
|
||||
import { Fruit } from "./Fruit";
|
||||
import { Board } from "./Board";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("FruitNode")
|
||||
export class FruitNode extends Component {
|
||||
|
||||
public fruitId: number = 0
|
||||
// fruit: Fruit = null!;
|
||||
// board: Board = null!;
|
||||
|
||||
// init(fruit: Fruit, board: Board) {
|
||||
// this.fruit = fruit;
|
||||
// this.board = board;
|
||||
|
||||
// this.node.on(Node.EventType.TOUCH_MOVE, this.onDragMove, this);
|
||||
// this.node.on(Node.EventType.TOUCH_END, this.onDragEnd, this);
|
||||
// }
|
||||
|
||||
// onDragMove(event: EventTouch) {
|
||||
// let delta = event.getDelta();
|
||||
// this.node.position = this.node.position.add(new Vec3(delta.x, delta.y, 0));
|
||||
// }
|
||||
|
||||
// onDragEnd() {
|
||||
// for (let r = 0; r < this.board.rows; r++) {
|
||||
// for (let c = 0; c < this.board.cols; c++) {
|
||||
// let target = this.board.board[r][c];
|
||||
// if (target && target !== this.fruit) {
|
||||
// let dist = this.node.position.subtract(target.node.position).length();
|
||||
// if (dist < 50) {
|
||||
// this.board.merge(this.fruit, target);
|
||||
// this.node.setPosition(target.node.position);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 回到原位
|
||||
// this.node.setPosition(new Vec3(this.fruit.col * 100, this.fruit.row * -100, 0));
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user