pixijs-migration-v8
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseThis skill is a breaking-change checklist for bringing a v7 codebase up to v8. Work top-down through the categories; the list maps each v7 pattern to its v8 replacement.
本Skill是一份将v7代码库升级到v8的破坏性变更检查清单。按从上到下的顺序处理各个分类;清单将每个v7模式映射到对应的v8替代方案。
Quick Start
快速开始
Install the single package, then port in this order: imports → Application init → Graphics → Text → events → shaders/filters → cleanup.
ts
const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
const g = new Graphics()
.rect(0, 0, 100, 100)
.fill({ color: 0xff0000 })
.stroke({ width: 2, color: 0x000000 });
app.stage.addChild(g);Related skills: (async init), (new fill/stroke API), (shader rework), (Text constructor changes), (destroy patterns).
pixijs-applicationpixijs-scene-graphicspixijs-custom-renderingpixijs-scene-textpixijs-performance安装单一包,然后按以下顺序迁移:导入 → Application初始化 → Graphics → Text → 事件 → 着色器/滤镜 → 清理。
ts
const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);
const g = new Graphics()
.rect(0, 0, 100, 100)
.fill({ color: 0xff0000 })
.stroke({ width: 2, color: 0x000000 });
app.stage.addChild(g);相关Skill: (异步初始化)、(新的填充/描边API)、(着色器重构)、(Text构造函数变更)、(销毁模式)。
pixijs-applicationpixijs-scene-graphicspixijs-custom-renderingpixijs-scene-textpixijs-performanceMigration Checklist: v7 to v8
迁移检查清单:v7 到 v8
Work through each category. Each item shows the expected v8 pattern and the v7 pattern that must be replaced.
逐个处理每个分类。每个条目展示了预期的v8模式以及必须替换的v7模式。
Initialization
初始化
Async app.init() -- Expected:
ts
const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);Fail: passing options to and using synchronously.
new Application({...})app.canvas replaces app.view -- emits a deprecation warning.
app.viewApplication type parameter -- Expected: . Fail: .
new Application<Renderer<HTMLCanvasElement>>()new Application<HTMLCanvasElement>()异步app.init() -- 预期写法:
ts
const app = new Application();
await app.init({ width: 800, height: 600 });
document.body.appendChild(app.canvas);错误写法:将选项传入并同步使用。
new Application({...})app.canvas替代app.view -- 会触发弃用警告。
app.viewApplication类型参数 -- 预期写法:。错误写法:。
new Application<Renderer<HTMLCanvasElement>>()new Application<HTMLCanvasElement>()Imports
导入
Single package -- Expected:
ts
import { Sprite, Application, Assets, Graphics } from "pixi.js";Fail: importing from any of the deprecated v7 core sub-packages (see list below). Supplemental packages like are still valid and should continue to be used.
@pixi/*@pixi/soundDeprecated packages (never use, any version):
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , .
@pixi/*@pixi/accessibility@pixi/app@pixi/assets@pixi/compressed-textures@pixi/core@pixi/display@pixi/events@pixi/extensions@pixi/extract@pixi/filter-alpha@pixi/filter-blur@pixi/filter-color-matrix@pixi/filter-displacement@pixi/filter-fxaa@pixi/filter-noise@pixi/graphics@pixi/mesh@pixi/mesh-extras@pixi/mixin-cache-as-bitmap@pixi/mixin-get-child-by-name@pixi/mixin-get-global-position@pixi/particle-container@pixi/prepare@pixi/sprite@pixi/sprite-animated@pixi/sprite-tiling@pixi/spritesheet@pixi/text@pixi/text-bitmap@pixi/text-htmlCustom builds -- Set and import only needed extensions:
skipExtensionImports: truets
import "pixi.js/graphics";
import "pixi.js/text";
import "pixi.js/events";
import { Application } from "pixi.js";
await app.init({ skipExtensionImports: true });Note: is still accepted but ; prefer .
manageImports: false@deprecated since 8.1.6skipExtensionImports: trueExtensions not auto-imported (require explicit import even with default auto-imports enabled):
, , , , , , , .
pixi.js/advanced-blend-modespixi.js/unsafe-evalpixi.js/preparepixi.js/math-extraspixi.js/ddspixi.js/ktxpixi.js/ktx2pixi.js/basisCommunity filters -- Expected: . Fail: .
import { AdjustmentFilter } from 'pixi-filters/adjustment'@pixi/filter-adjustment单一包 -- 预期写法:
ts
import { Sprite, Application, Assets, Graphics } from "pixi.js";错误写法:从任何已弃用的v7核心子包导入(见下方列表)。等补充包仍然有效,可继续使用。
@pixi/*@pixi/sound已弃用的包(任何版本均禁止使用):
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , 。
@pixi/*@pixi/accessibility@pixi/app@pixi/assets@pixi/compressed-textures@pixi/core@pixi/display@pixi/events@pixi/extensions@pixi/extract@pixi/filter-alpha@pixi/filter-blur@pixi/filter-color-matrix@pixi/filter-displacement@pixi/filter-fxaa@pixi/filter-noise@pixi/graphics@pixi/mesh@pixi/mesh-extras@pixi/mixin-cache-as-bitmap@pixi/mixin-get-child-by-name@pixi/mixin-get-global-position@pixi/particle-container@pixi/prepare@pixi/sprite@pixi/sprite-animated@pixi/sprite-tiling@pixi/spritesheet@pixi/text@pixi/text-bitmap@pixi/text-html自定义构建 -- 设置并仅导入所需扩展:
skipExtensionImports: truets
import "pixi.js/graphics";
import "pixi.js/text";
import "pixi.js/events";
import { Application } from "pixi.js";
await app.init({ skipExtensionImports: true });注意:仍可接受,但;优先使用。
manageImports: false@deprecated since 8.1.6skipExtensionImports: true不会自动导入的扩展(即使启用默认自动导入,也需要显式导入):
, , , , , , , 。
pixi.js/advanced-blend-modespixi.js/unsafe-evalpixi.js/preparepixi.js/math-extraspixi.js/ddspixi.js/ktxpixi.js/ktx2pixi.js/basis社区滤镜 -- 预期写法:。错误写法:。
import { AdjustmentFilter } from 'pixi-filters/adjustment'@pixi/filter-adjustmentGraphics API
Graphics API
Shape-then-fill -- Expected:
ts
const g = new Graphics().rect(50, 50, 100, 100).fill(0xff0000);Fail: .
beginFill(0xff0000).drawRect(50, 50, 100, 100).endFill()Renamed shape methods:
| v7 | v8 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Fill replaces beginFill/beginTextureFill -- Expected:
ts
graphics
.rect(0, 0, 100, 100)
.fill({ texture: Texture.WHITE, alpha: 0.5, color: 0xff0000 });Fail: or .
beginFill(color, alpha)beginTextureFill({ texture, alpha, color })Stroke replaces lineStyle -- Expected:
ts
graphics.rect(0, 0, 100, 100).fill("blue").stroke({ width: 2, color: "white" });Fail: or .
lineStyle(2, 'white')lineTextureStyle({ texture, width, color })Holes use cut() -- Expected:
ts
graphics.rect(0, 0, 100, 100).fill(0x00ff00).circle(50, 50, 20).cut();Fail: / .
beginHole()endHole()GraphicsContext replaces GraphicsGeometry -- Expected:
ts
const context = new GraphicsContext().rect(0, 0, 100, 100).fill(0xff0000);
const g1 = new Graphics(context);
const g2 = new Graphics(context);Fail: .
new Graphics(graphics.geometry)先绘形状再填充 -- 预期写法:
ts
const g = new Graphics().rect(50, 50, 100, 100).fill(0xff0000);错误写法:。
beginFill(0xff0000).drawRect(50, 50, 100, 100).endFill()重命名的形状方法:
| v7 | v8 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Fill替代beginFill/beginTextureFill -- 预期写法:
ts
graphics
.rect(0, 0, 100, 100)
.fill({ texture: Texture.WHITE, alpha: 0.5, color: 0xff0000 });错误写法:或。
beginFill(color, alpha)beginTextureFill({ texture, alpha, color })Stroke替代lineStyle -- 预期写法:
ts
graphics.rect(0, 0, 100, 100).fill("blue").stroke({ width: 2, color: "white" });错误写法:或。
lineStyle(2, 'white')lineTextureStyle({ texture, width, color })使用cut()绘制孔洞 -- 预期写法:
ts
graphics.rect(0, 0, 100, 100).fill(0x00ff00).circle(50, 50, 20).cut();错误写法: / 。
beginHole()endHole()GraphicsContext替代GraphicsGeometry -- 预期写法:
ts
const context = new GraphicsContext().rect(0, 0, 100, 100).fill(0xff0000);
const g1 = new Graphics(context);
const g2 = new Graphics(context);错误写法:。
new Graphics(graphics.geometry)Text
Text
Options object constructor -- Expected:
ts
const text = new Text({ text: "Hello", style: { fontSize: 24 } });
const bmp = new BitmapText({ text: "Hello", style: { fontFamily: "MyFont" } });
const html = new HTMLText({ text: "<b>Hello</b>", style: { fontSize: 24 } });Fail: (positional args).
new Text('Hello', { fontSize: 24 })Bitmap font loading -- Must before .
import 'pixi.js/text-bitmap'Assets.load('font.fnt')选项对象构造函数 -- 预期写法:
ts
const text = new Text({ text: "Hello", style: { fontSize: 24 } });
const bmp = new BitmapText({ text: "Hello", style: { fontFamily: "MyFont" } });
const html = new HTMLText({ text: "<b>Hello</b>", style: { fontSize: 24 } });错误写法:(位置参数)。
new Text('Hello', { fontSize: 24 })位图字体加载 -- 必须在之前导入。
Assets.load('font.fnt')'pixi.js/text-bitmap'Sprites / Mesh
精灵 / 网格
Texture.from no longer loads URLs -- Must call first, then .
await Assets.load('image.png')Texture.from('image.png')NineSliceSprite replaces NineSlicePlane -- Expected:
ts
const ns = new NineSliceSprite({
texture,
leftWidth: 10,
topHeight: 10,
rightWidth: 10,
bottomHeight: 10,
});Mesh renames: -> , -> , -> . All use options objects.
SimpleMeshMeshSimpleSimplePlaneMeshPlaneSimpleRopeMeshRopeMeshGeometry options -- Expected:
ts
const geom = new MeshGeometry({
positions: vertices,
uvs,
indices,
topology: "triangle-list",
});Fail: .
new MeshGeometry(vertices, uvs, indices)ParticleContainer uses Particle -- Expected:
ts
const container = new ParticleContainer({
boundsArea: new Rectangle(0, 0, 800, 600),
});
const particle = new Particle(texture);
container.addParticle(particle);Fail: .
container.addChild(new Sprite(texture))Texture.from不再加载URL -- 必须先调用,再调用。
await Assets.load('image.png')Texture.from('image.png')NineSliceSprite替代NineSlicePlane -- 预期写法:
ts
const ns = new NineSliceSprite({
texture,
leftWidth: 10,
topHeight: 10,
rightWidth: 10,
bottomHeight: 10,
});Mesh重命名: -> , -> , -> 。所有类均使用选项对象。
SimpleMeshMeshSimpleSimplePlaneMeshPlaneSimpleRopeMeshRopeMeshGeometry选项 -- 预期写法:
ts
const geom = new MeshGeometry({
positions: vertices,
uvs,
indices,
topology: "triangle-list",
});错误写法:。
new MeshGeometry(vertices, uvs, indices)ParticleContainer使用Particle -- 预期写法:
ts
const container = new ParticleContainer({
boundsArea: new Rectangle(0, 0, 800, 600),
});
const particle = new Particle(texture);
container.addParticle(particle);错误写法:。
container.addChild(new Sprite(texture))Events
事件
eventMode replaces interactive -- Expected:
ts
sprite.eventMode = "static";
sprite.cursor = "pointer";
sprite.on("pointertap", () => {
/* handle */
});Legacy: (still works as an alias for , but prefer the explicit form).
sprite.interactive = true;eventMode = 'static'Default is (no events). Must set or explicitly.
eventMode'passive''static''dynamic'Ticker callback -- Expected:
ts
app.ticker.add((ticker) => {
bunny.rotation += ticker.deltaTime;
});Broken: -- compiles but is a object, not a number. Coerces to , silently corrupting rotation.
app.ticker.add((dt) => { bunny.rotation += dt; })dtTickerNaNupdateTransform removed -- Use in constructor instead.
this.onRender = this._onRender.bind(this)eventMode替代interactive -- 预期写法:
ts
sprite.eventMode = "static";
sprite.cursor = "pointer";
sprite.on("pointertap", () => {
/* 处理逻辑 */
});遗留写法:(仍可作为的别名,但推荐使用显式写法)。
sprite.interactive = true;eventMode = 'static'默认为(不响应事件)。必须显式设置为或。
eventMode'passive''static''dynamic'Ticker回调 -- 预期写法:
ts
app.ticker.add((ticker) => {
bunny.rotation += ticker.deltaTime;
});错误写法: -- 可以编译,但是对象而非数字,会被转换为,导致旋转值静默损坏。
app.ticker.add((dt) => { bunny.rotation += dt; })dtTickerNaNupdateTransform已移除 -- 改为在构造函数中使用。
this.onRender = this._onRender.bind(this)Shaders
着色器
Shader.from uses options -- Expected:
ts
const shader = Shader.from({
gl: { vertex: vertexSrc, fragment: fragmentSrc },
resources: {
myUniforms: new UniformGroup({ uTime: { value: 0, type: "f32" } }),
},
});Fail: .
Shader.from(vertex, fragment, uniforms)Filter constructor -- Expected:
ts
const filter = new Filter({
glProgram: GlProgram.from({ fragment, vertex }),
resources: { filterUniforms: { uTime: { value: 0, type: "f32" } } },
});Fail: .
new Filter(vertex, fragment, { uTime: 0 })Uniforms require type -- . Fail: .
new UniformGroup({ uTime: { value: 1, type: 'f32' } })new UniformGroup({ uTime: 1 })Textures are resources, not uniforms -- Pass as top-level resource entries (, ), not inside UniformGroup.
texture.sourcetexture.styleShader.from使用选项 -- 预期写法:
ts
const shader = Shader.from({
gl: { vertex: vertexSrc, fragment: fragmentSrc },
resources: {
myUniforms: new UniformGroup({ uTime: { value: 0, type: "f32" } }),
},
});错误写法:。
Shader.from(vertex, fragment, uniforms)Filter构造函数 -- 预期写法:
ts
const filter = new Filter({
glProgram: GlProgram.from({ fragment, vertex }),
resources: { filterUniforms: { uTime: { value: 0, type: "f32" } } },
});错误写法:。
new Filter(vertex, fragment, { uTime: 0 })Uniforms需要指定类型 -- 。错误写法:。
new UniformGroup({ uTime: { value: 1, type: 'f32' } })new UniformGroup({ uTime: 1 })纹理是资源而非uniforms -- 作为顶级资源条目传递(, ),而非放在UniformGroup内。
texture.sourcetexture.styleTextures
纹理
Sprite no longer auto-detects texture UV changes -- If you modify a texture's frame after creation, call to recalculate UVs, then call to refresh the sprite. Both calls are required in this order. Updating source data (e.g. video textures) is still automatic.
texture.update()sprite.onViewUpdate()ts
texture.frame.width = texture.frame.width / 2;
texture.update(); // recalculate texture UVs first
sprite.onViewUpdate(); // then refresh the sprite's displayMipmaps -- renamed to . For RenderTextures, you must manually update mipmaps:
BaseTexture.mipmapautoGenerateMipmapsts
const rt = RenderTexture.create({
width: 100,
height: 100,
autoGenerateMipmaps: true,
});
renderer.render({ target: rt, container: scene });
rt.source.updateMipmaps();Sprite不再自动检测纹理UV变化 -- 如果在创建后修改纹理的frame,需先调用重新计算UV,再调用刷新精灵。必须按此顺序调用这两个方法。源数据更新(如视频纹理)仍为自动触发。
texture.update()sprite.onViewUpdate()ts
texture.frame.width = texture.frame.width / 2;
texture.update(); // 先重新计算纹理UV
sprite.onViewUpdate(); // 再刷新精灵显示Mipmaps -- 重命名为。对于RenderTextures,必须手动更新mipmaps:
BaseTexture.mipmapautoGenerateMipmapsts
const rt = RenderTexture.create({
width: 100,
height: 100,
autoGenerateMipmaps: true,
});
renderer.render({ target: rt, container: scene });
rt.source.updateMipmaps();Adapters
适配器
DOMAdapter replaces settings.ADAPTER -- Expected:
ts
import { DOMAdapter, WebWorkerAdapter } from "pixi.js";
DOMAdapter.set(WebWorkerAdapter);
DOMAdapter.get().createCanvas();Fail: .
settings.ADAPTER = WebWorkerAdapter; settings.ADAPTER.createCanvas();Built-in adapters: (default), (for web workers).
BrowserAdapterWebWorkerAdapterDOMAdapter替代settings.ADAPTER -- 预期写法:
ts
import { DOMAdapter, WebWorkerAdapter } from "pixi.js";
DOMAdapter.set(WebWorkerAdapter);
DOMAdapter.get().createCanvas();错误写法:。
settings.ADAPTER = WebWorkerAdapter; settings.ADAPTER.createCanvas();内置适配器:(默认)、(用于Web Worker)。
BrowserAdapterWebWorkerAdapterOther
其他
DisplayObject removed -- is the base class. fails.
Containerclass MyObj extends DisplayObjectLeaf nodes cannot have children -- , , , are leaf nodes. Wrap in .
SpriteGraphicsMeshTextContainerRenamed properties (old names still exist as deprecated aliases with warnings):
- ->
container.namecontainer.label - ->
container.cacheAsBitmap = truecontainer.cacheAsTexture(true)
getBounds() return type changed: now returns a object, not a . has , , , getters, so basic usage works. Use when you need a instance (e.g., for ).
getBounds()BoundsRectangleBounds.x.y.width.height.rectangleRectangle.contains()settings object removed -- Use and .
AbstractRenderer.defaultOptions.resolution = 1DOMAdapter.set(BrowserAdapter)utils namespace removed -- instead of .
import { isMobile } from 'pixi.js'utils.isMobileText parser renames:
- ->
TextFormatbitmapFontTextParser - ->
XMLStringFormatbitmapFontXMLStringParser - ->
XMLFormatbitmapFontXMLParser
Assets.add -- . Fail: .
Assets.add({ alias: 'bunny', src: 'bunny.png' })Assets.add('bunny', 'bunny.png')Enum constants replaced with strings:
| v7 | v8 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Culling is manual -- Set , then call before render. Or add via .
cullable = trueCuller.shared.cull(container, viewRect)CullerPluginextensions.add(CullerPlugin)DisplayObject已移除 -- 是基类。会报错。
Containerclass MyObj extends DisplayObject叶子节点不能包含子节点 -- 、、、均为叶子节点,需用包裹。
SpriteGraphicsMeshTextContainer重命名的属性(旧名称仍作为已弃用别名存在,会触发警告):
- ->
container.namecontainer.label - ->
container.cacheAsBitmap = truecontainer.cacheAsTexture(true)
getBounds()返回类型变更: 现在返回对象而非。拥有, , , getter,因此基础用法不受影响。当需要实例时(如调用),使用属性。
getBounds()BoundsRectangleBounds.x.y.width.heightRectangle.contains().rectanglesettings对象已移除 -- 使用和。
AbstractRenderer.defaultOptions.resolution = 1DOMAdapter.set(BrowserAdapter)utils命名空间已移除 -- 使用替代。
import { isMobile } from 'pixi.js'utils.isMobile文本解析器重命名:
- ->
TextFormatbitmapFontTextParser - ->
XMLStringFormatbitmapFontXMLStringParser - ->
XMLFormatbitmapFontXMLParser
Assets.add -- 。错误写法:。
Assets.add({ alias: 'bunny', src: 'bunny.png' })Assets.add('bunny', 'bunny.png')枚举常量替换为字符串:
| v7 | v8 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
剔除(Culling)需手动触发 -- 设置,然后在渲染前调用。或通过添加。
cullable = trueCuller.shared.cull(container, viewRect)extensions.add(CullerPlugin)CullerPluginPre-Migration Summary
迁移前检查清单
- No deprecated v7 core packages in dependencies (supplemental packages like
@pixi/*are fine)@pixi/sound - All core imports converted to
@pixi/*pixi.js - All converted to
new Application({...})await app.init({...}) - All Graphics code uses shape-then-fill pattern
- All constructors use options objects (Text, Mesh, NineSliceSprite, etc.)
- Shader/Filter code uses pattern with typed uniforms
{gl, resources} - ParticleContainer code uses , not
ParticleSprite - Ticker callbacks access , not first param as delta
ticker.deltaTime - Event handling uses instead of
eventModeinteractive - and
settingsreferences removedutils - references replaced with
DisplayObjectContainer - Texture UV modifications call where needed
sprite.onViewUpdate() - RenderTexture mipmap code calls manually
source.updateMipmaps() - replaced with
settings.ADAPTERDOMAdapter.set()
- 依赖中没有已弃用的v7核心包(
@pixi/*等补充包没问题)@pixi/sound - 所有核心导入已转换为
@pixi/*pixi.js - 所有已转换为
new Application({...})await app.init({...}) - 所有Graphics代码使用先绘形状再填充的模式
- 所有构造函数使用选项对象(Text、Mesh、NineSliceSprite等)
- 着色器/滤镜代码使用带类型uniforms的模式
{gl, resources} - ParticleContainer代码使用而非
ParticleSprite - Ticker回调访问,而非将第一个参数视为delta值
ticker.deltaTime - 事件处理使用而非
eventModeinteractive - 已移除和
settings引用utils - 引用已替换为
DisplayObjectContainer - 修改纹理UV时,在需要的地方调用
sprite.onViewUpdate() - RenderTexture mipmap代码手动调用
source.updateMipmaps() - 已替换为
settings.ADAPTERDOMAdapter.set()
Common Mistakes
常见错误
[CRITICAL] Importing from deprecated v7 core @pixi/* sub-packages
[CRITICAL] 从已弃用的v7核心@pixi/*子包导入
Wrong:
ts
import { Sprite } from "@pixi/sprite";
import { Application } from "@pixi/app";Correct:
ts
import { Sprite, Application } from "pixi.js";v8 uses a single package. The v7 core sub-packages are deprecated and must not be used (see the full list under Imports above). Supplemental packages like are still valid.
pixi.js@pixi/*@pixi/sound错误写法:
ts
import { Sprite } from "@pixi/sprite";
import { Application } from "@pixi/app";正确写法:
ts
import { Sprite, Application } from "pixi.js";v8使用单一包。v7核心子包已弃用,禁止使用(见上方导入部分的完整列表)。等补充包仍然有效。
pixi.js@pixi/*@pixi/sound[CRITICAL] Using DisplayObject as base class
[CRITICAL] 使用DisplayObject作为基类
Wrong:
Correct:
class MyObject extends DisplayObject { ... }class MyObject extends Container { ... }DisplayObjectContainer错误写法:
正确写法:
class MyObject extends DisplayObject { ... }class MyObject extends Container { ... }DisplayObjectContainer[HIGH] Using old SCALE_MODES/WRAP_MODES/DRAW_MODES enums
[HIGH] 使用旧的SCALE_MODES/WRAP_MODES/DRAW_MODES枚举
Wrong:
Correct:
texture.source.scaleMode = SCALE_MODES.NEAREST;texture.source.scaleMode = 'nearest';v8 uses string values. Old enums may work as deprecated aliases but should be replaced.
错误写法:
正确写法:
texture.source.scaleMode = SCALE_MODES.NEAREST;texture.source.scaleMode = 'nearest';v8使用字符串值。旧枚举可能仍可作为已弃用别名工作,但应替换为新写法。
[HIGH] Using interactive = true
instead of eventMode
interactive = trueeventMode[HIGH] 使用interactive = true
而非eventMode
interactive = trueeventModeLegacy: (still works as an alias for )
Preferred:
sprite.interactive = true;eventMode = 'static'sprite.eventMode = 'static';Default is (no events). Must set (hit-testable, no tick checks) or (hit-testable with tick checks) explicitly. still works without a deprecation warning, but is the canonical v8 API.
eventMode'passive''static''dynamic'interactive = trueeventMode遗留写法:(仍可作为的别名)
推荐写法:
sprite.interactive = true;eventMode = 'static'sprite.eventMode = 'static';默认为(不响应事件)。必须显式设置为(可命中测试,无tick检查)或(可命中测试,带tick检查)。仍可正常使用且无弃用警告,但是v8的标准API。
eventMode'passive''static''dynamic'interactive = trueeventMode[HIGH] Using utils namespace
[HIGH] 使用utils命名空间
Wrong:
Correct:
import { utils } from 'pixi.js'; utils.isMobile.any();import { isMobile } from 'pixi.js'; isMobile.any();The namespace was removed. All utility functions are direct imports.
utils错误写法:
正确写法:
import { utils } from 'pixi.js'; utils.isMobile.any();import { isMobile } from 'pixi.js'; isMobile.any();utils[HIGH] Expecting texture UV changes to auto-update sprites
[HIGH] 认为纹理UV变化会自动更新精灵
Wrong: modifying and assuming the sprite updates automatically.
Correct: call after modifying texture UVs.
texture.framesprite.onViewUpdate()Sprites no longer subscribe to texture UV change events for performance. Source data updates (e.g. video) still auto-reflect.
错误写法:修改并假设精灵会自动更新。
正确写法:修改纹理UV后调用。
texture.framesprite.onViewUpdate()为提升性能,精灵不再订阅纹理UV变化事件。源数据更新(如视频)仍会自动反映到精灵上。