当前位置: 首页 > news >正文

【cocos creator】2.x,伪3d拖拽,45度视角,60度视角,房屋装扮

伪3d拖拽,45度视角,60度视角
工程下载:(待审核)
https://download.csdn.net/download/K86338236/89530812

在这里插入图片描述

dragItem2.t s


import mapCreat2 from "./mapCreat2";const { ccclass, property } = cc._decorator;
/*** 拖拽类,挂在要拖拽的节点上*/
@ccclass
export default class dragItem2 extends cc.Component {@property(mapCreat2)mapCreat: mapCreat2 = null;private _originPos: cc.Vec2;private _startPos: any;oginPos: any;colRowPos = cc.v3(0, 0, 0)onLoad() {this.oginPos = this.node.position;this.regiestNodeEvent(this.node.children[0] || this.node);}init(pos) {this.colRowPos = pos;}/** 节点注册事件 */regiestNodeEvent(node: cc.Node) {if (!node) return;node.on(cc.Node.EventType.TOUCH_START, this.touchStartEvent, this);node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMoveEvent, this);node.on(cc.Node.EventType.TOUCH_END, this.touchEndEvent, this);node.on(cc.Node.EventType.TOUCH_CANCEL, this.touchEndEvent, this);}touchStartEvent(event) {console.log('touch start--------')this._originPos = this.node.getPosition();this._startPos = event.getLocation();this.node.zIndex = 9999;this.mapCreat.removeBox(this.colRowPos)}touchMoveEvent(event) {let pos = event.getLocation();if (!this._startPos) {return;}let offset_x = pos.x - this._startPos.x;let offset_y = pos.y - this._startPos.y;this.node.x = this._originPos.x + offset_x;this.node.y = this._originPos.y + offset_y;}touchEndEvent(event) {this._startPos = null;this.setPos(false)}setPos(isInit?) {const { endPos, col, row, layer } = this.mapCreat.getPutPos(this.node, isInit, this.colRowPos)if (!endPos) returnthis.node.position = endPos;this.colRowPos = cc.v3(col, row, layer);this.mapCreat.addBox(cc.v3(col, row, layer))this.node.zIndex = -col * 10 - row * 10 + layer;}
}

mapCreat2.ts

import dragItem from "./dragItem";const { ccclass, property } = cc._decorator;@ccclass
export default class mapCreat extends cc.Component {//可修改mapH = 10;     // 地图纵向格子数量mapW = 10;     // 地图横向格子数量_layerH = 64.3;     // 地图单元格子高度,根据ui素材调整_gridW = 64.3;   // 地图单元格子长度,根据ui素材调整_gridH = 19;   // 地图单元格子宽度,根据ui素材调整boxAngel = 52;//地图伪3d角度,根据ui素材调整
http://www.lryc.cn/news/397841.html

相关文章:

  • 【thingsbord源码编译】 显示node内存不足
  • 内存巨头SK海力士正深化与TSMC/NVIDIA合作关系,开发下一代HBM
  • 基于Pinia的WebSocket管理与优化实践(实现心跳重连机制,异步发送)
  • Perl词法作用域:自定义编程环境的构建术
  • vscode使用ssh连接远程服务器
  • linux 常用和不那么常用命令记录02 磁盘占用
  • mybatis日志记录方案
  • 【LeetCode】最长连续序列
  • Windows下终端Kafka指令常用操作
  • QT---lineEdit相关信号
  • 基于vue的地图特效(飞线和标注)
  • 生物环保技术有哪些缺点或者局限性呢
  • 我被手机所伤,竟如此憔悴。
  • 【深度学习】第3章实验——回归模型
  • MYSQL 四、mysql进阶 8(索引优化与查询优化)
  • python | pyvips,一个神奇的 Python 库
  • STM32利用FreeRTOS实现4个led灯同时以不同的频率闪烁
  • 深入Laravel事件系统:创建与使用事件的指南
  • element-ui操作表格行内容如何获取当前行索引?
  • 代发考生战报:南京考场华为售前HCSP H19-411考试通过
  • 【Spring Boot】Spring原理:Bean的作用域和生命周期
  • MinIO:开源对象存储解决方案的领先者
  • 15、电科院FTU检测标准学习笔记-基本性能
  • 古建筑倾斜在线监测系统:科技守护历史的创新实践
  • DP(2) | Java | LeetCode 62, 63, 343, 96 做题总结(96 未完)
  • Ubuntu实战续篇:Apache httpd轻松搭建高效代理服务器
  • Linux 程序卡死的特殊处理
  • (C++字符串02) 反转字符串中的单词
  • 一致性Hash问题及解决方案
  • 【接口设计】如何设计统一 RESTful 风格的数据接口