12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import { _decorator, Color, Component, Label, Node, Sprite,tween,Vec3 } from 'cc';
- const { ccclass, property } = _decorator;
- class BindTarget{
- color : Color
- }
- @ccclass('Item')
- export class Item extends Component {
- numType:number;
- row:number;
- col:number;
- //是否已经处于变色区域内
- isLock:boolean;
- start() {
- }
- init(_numType,_row,_col){
- this.numType=_numType
- this.row=_row
- this.col=_col
- this.showUI()
- }
- changeType(_numType){
- this.numType=_numType
- this.showUI()
- }
- showUI(){
- // let colorArr=[Color.RED,Color.GREEN,Color.BLUE,Color.YELLOW,Color.GRAY,Color.WHITE]
- let colorArr=[new Color(0,192,196,255),new Color(112,196,0,255),new Color(255,4,112,255),new Color(255,221,0,255)]
- let label=this.node.getChildByName("Label").getComponent(Label)
- label.string="";//this.numType+"|"+this.row+","+this.col
- this.node.getChildByName("SpriteSplash").getComponent(Sprite).color=colorArr[this.numType]
- this.node.scale=new Vec3(0.7,0.7,1)
- tween(this.node)
- .to(0.2, {
- scale: new Vec3(1, 1, 1), // 缩放缓动
- }
- )
- .start();
- }
- update(deltaTime: number) {
-
- }
- }
|