cocos屏幕坐标转游戏坐标

实际上2d游戏使用getUIPosition即可,无需屏幕转游戏坐标let node: Node = event.target let { x, y } = event.getLocation() let re = this.camera.screenToWorld(new Vec3(x, y, 0), node.getWorldPosition()) this.body.setWorldPosi

- 阅读全文 -

cocos对于touch坐标和node坐标理解

Touch(屏幕坐标非游戏坐标)getLocation x轴为相对设计尺寸左下角距离getLocationInView x轴为相对视窗左侧距离,y轴为相对视窗中心距离getUILocation 游戏中相对左下角xy距离的坐标(若屏幕无缩放则与getLocation)无差异Node:getLocation为相对锚点坐标getWorldPosition为锚点相对左下角坐标console.log(&qu

- 阅读全文 -

atlas文件分割脚本

安装最上面的几个库就行,大部分python应该都有import os import json from PIL import Image import sys # 确保Python使用UTF-8编码 sys.stdout.reconfigure(encoding='utf-8') def parse_atlas(atlas_path): # 读取Atlas文件,确保使用UTF-8编码

- 阅读全文 -

js中this指向

作为函数直接调用 this 指向为 window,作为对象/类中函数调用 this 指向为 对象/类箭头函数 () => {} 传入调用则 this 指向为传入时的类/对象参考如下代码,可以简单理解 function a() { console.log(this); } a() // window class B { name =

- 阅读全文 -

// 行号插件