【cocos creator】2.4.x实现简单3d功能,点击选中,旋转,材质修改,透明材质

demo下载:(待审核)
https://download.csdn.net/download/K86338236/89527924


const {
    ccclass, property } = cc._decorator;

const enum box_color {
   
    NORMAL = 0,
    DASHED_LINE = 1,//虚线
    TRANSLUCENT = 2,//半透明
}

@ccclass
export default class main extends cc.Component {
   
    @property(cc.Node)
    boxNode: cc.Node = null;
    @property(cc.Node)
    layerNode: cc.Node = null;

    /**层的父节点 */
    @property(cc.Node)
    layerRootNode: cc.Node = null;

    /**点击检测射线 */
    @property(cc.Node)
    touchNode: cc.Node = null;

    /**普通的颜色 */
    @property([cc.Material])
    changeMat: cc.Material[] = [];
    /**普通颜色第二层,半透明用 */
    @property([cc.Material])
    changeMat2: cc.Material[] = [];
    /**选择状态的颜色 */
    @property([cc.Material])
    changeMatChoose: cc.Material[] = [];
    @property([cc.Material])
    changeMatChoose2: cc.Material[] = [];

    /**向左旋转45 */
    @property(cc.Button)
    leftBtn: cc.Button = null;

    /**向右旋转45 */
    @property(cc.Button)
    rightBtn: cc.Button = null;

    /**分离、合起 */
    @property(cc.Button)
    divideBtn: cc.Button = null;

    /**已经修改颜色uid物体 */
    changeUids: string[] = [];

    /**当前分离状态,是否分离 */
    curDivideState: boolean = false;

    /**当前角度 */
    curAngle: number = 0;

    /**是否动作中 */
    isPlay: boolean = false;


    /**当前角度 */
    choose_type: number = 0;

    // onLoad () {}

    start() {
   
        this.setAngle(-15)
        cc.director.getPhysics3DManager().enabled = true;
        this.touchNode.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        let boxArr = ["1,1|1,2|1,3|2,1|2,2|3,1", 

相关推荐

  1. CocosCreator3.x相机实践

    2024-07-10 02:36:09       20 阅读
  2. Qt3D 材质模块使用说明

    2024-07-10 02:36:09       44 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 02:36:09       50 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 02:36:09       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 02:36:09       43 阅读
  4. Python语言-面向对象

    2024-07-10 02:36:09       54 阅读

热门阅读

  1. 基于 LSN 的 PostgreSQL 数据管理与恢复

    2024-07-10 02:36:09       22 阅读
  2. 加密货币安全升级:USDT地址监控机器人

    2024-07-10 02:36:09       20 阅读
  3. bind方法的使用

    2024-07-10 02:36:09       15 阅读
  4. 128陷阱详解

    2024-07-10 02:36:09       15 阅读
  5. 前端如何控制并发请求

    2024-07-10 02:36:09       15 阅读
  6. ubuntu虚拟机安装

    2024-07-10 02:36:09       20 阅读
  7. RabbitMQ安装使用遇到的问题

    2024-07-10 02:36:09       18 阅读
  8. ShardingSphere

    2024-07-10 02:36:09       20 阅读
  9. Docker启动安装nacos

    2024-07-10 02:36:09       20 阅读
  10. 设置Nginx响应超时配置

    2024-07-10 02:36:09       25 阅读
  11. 每周算法(week2)【leetcode11~30】

    2024-07-10 02:36:09       21 阅读