惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Troy Hunt's Blog
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
S
Securelist
H
Help Net Security
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Secure Thoughts
Spread Privacy
Spread Privacy
C
Check Point Blog
WordPress大学
WordPress大学
AWS News Blog
AWS News Blog
L
Lohrmann on Cybersecurity
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Privacy International News Feed
T
The Exploit Database - CXSecurity.com
N
News and Events Feed by Topic
Blog — PlanetScale
Blog — PlanetScale
PCI Perspectives
PCI Perspectives
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Cyber Attacks, Cyber Crime and Cyber Security
Google Online Security Blog
Google Online Security Blog
The Hacker News
The Hacker News
宝玉的分享
宝玉的分享
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cisco Blogs
Last Week in AI
Last Week in AI
Webroot Blog
Webroot Blog
GbyAI
GbyAI
I
InfoQ
罗磊的独立博客
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
Latest news
Latest news
P
Palo Alto Networks Blog
博客园 - Franky
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Security Affairs
H
Hacker News: Front Page
P
Privacy & Cybersecurity Law Blog
小众软件
小众软件
The Register - Security
The Register - Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog
V
Vulnerabilities – Threatpost
人人都是产品经理
人人都是产品经理
博客园_首页
aimingoo的专栏
aimingoo的专栏

博客园 - kingBook

git patch git 修改最后一次提交的日期 Win10 修改特定格式文件的右键快捷菜单 TypeScript async、 await、Promise LayaAir3.x 侦听程序退出 旋转力学例子 旋转力学公式 凹多边形碰撞检测 LayaAir3.x 侦听键盘事件 URP 阴影 TypeScript 里的 override TypeScript 类的自身类型 Unity 二维数组序列化 C# 匿名对象、动态属性 Cocos Creator 安卓模拟器中无法运行 Unity Editor 保存图片、缩放纹理 LayaAir3.x 物理2D碰撞事件 TypeScirpt 声明Map类型变量 TypeScript 声明函数类型变量
LayaAir3.2.0-beta.2 设置2d刚体线性速度,在不同设备(分辨率)下,表现不一致的问题
kingBook · 2024-08-01 · via 博客园 - kingBook
private _body: Laya.RigidBody;
private _speed: number = 20;

let radian = this.owner.rotation * Math.PI / 180;
// 注意:需要除以 Laya.Browser.pixelRatio
let v = new Laya.Vector2(Math.cos(radian) * this._speed / Laya.Browser.pixelRatio, 
                         Math.sin(radian) * this._speed / Laya.Browser.pixelRatio);
this._body.setVelocity(v);

根据源码:src/layaAir/laya/physics/factory/physics2DwasmFactory.ts

// physics2DwasmFactory.ts

 /**
  * @en Create the Box2D world.
  * @zh 创建Box2D世界。
  */
start() {
    this._PIXEL_RATIO = Physics2DOption.pixelRatio * Browser.pixelRatio;
    //...
}

由于其在使用像素到米单位时使用了 Browser.pixelRatio (设备像素比),这会导致直接设置线性速度,会在不同的设备像素比时表现不一致
注: 在 LayaAir3.2.0-beta.3 官方已修复了此问题,不再需要除以 Laya.Browser.pixelRatio,在不同的设备像素比时已经表现一致