| name | cocos-performance-optimizer |
| description | Use when working on performance issues, optimization strategies, or when targeting low-end devices. |
Cocos Performance Optimizer
Overview
This Codex skill adapts the upstream Cocos Creator Claude agent guidance for use in Codex.
Expert in optimizing Cocos Creator games for maximum performance across all platforms. Use this skill for performance issues, optimization strategies, or when targeting low-end devices.
Expertise
- Draw call optimization
- Texture atlasing and compression
- Object pooling strategies
- Render batching techniques
- Memory profiling and management
- JavaScript/TypeScript optimization
- Asset loading optimization
- Frame rate stabilization
Usage Examples
Example 1: Mobile Optimization
Context: Game running slowly on mobile
User: "Optimize game to run at 60 FPS on mid-range phones"
Assistant: "I will use $cocos-performance-optimizer"
Commentary: Analyzes bottlenecks and implements targeted optimizations
Example 2: Memory Management
Context: Memory leaks causing crashes
User: "Fix memory issues in level transitions"
Assistant: "I will use $cocos-performance-optimizer"
Commentary: Identifies leaks and implements proper cleanup
Example 3: Rendering Optimization
Context: Too many draw calls
User: "Reduce draw calls in the game scene"
Assistant: "I will use $cocos-performance-optimizer"
Commentary: Implements sprite batching and mesh combining
Optimization Strategies
Draw Call Reduction
@ccclass('BatchOptimizer')
export class BatchOptimizer extends Component {
@property([SpriteFrame])
spriteFrames: SpriteFrame[] = [];
private _atlas: SpriteAtlas = null;
onLoad() {
this.createDynamicAtlas();
this.enableBatching();
}
createDynamicAtlas() {
this._atlas = new SpriteAtlas();
this.spriteFrames.forEach(frame => {
this._atlas.addSpriteFrame(frame);
});
}
enableBatching() {
const sprites = this.node.getComponentsInChildren(Sprite);
sprites.forEach(sprite => {
sprite.enableBatch = true;
});
}
}
Performance Metrics
- Draw Calls: < 100 (mobile), < 300 (desktop)
- Triangles: < 100k (mobile), < 500k (desktop)
- Texture Memory: < 128MB (mobile), < 512MB (desktop)
- JavaScript Heap: < 100MB (mobile), < 300MB (desktop)
Object Pooling
@ccclass('ObjectPool')
export class ObjectPool<T extends Component> {
private _pool: T[] = [];
private _prefab: Prefab;
private _componentType: { new(): T };
get(parent: Node): T {
let obj: T;
if (this._pool.length > 0) {
obj = this._pool.pop();
obj.node.setParent(parent);
obj.node.active = true;
} else {
const node = instantiate(this._prefab);
node.setParent(parent);
obj = node.getComponent(this._componentType);
}
return obj;
}
put(obj: T) {
obj.node.active = false;
this._pool.push(obj);
}
}
Platform-Specific Tips
Mobile (iOS/Android)
- Use compressed textures (ETC1/2, PVRTC)
- Limit particle effects
- Reduce shadow quality
- Use LOD for 3D models
- Minimize transparent overdraw
Web (HTML5)
- Optimize initial loading
- Use texture compression (WebP)
- Implement progressive loading
- Minimize bundle size
- Use Web Workers for heavy computation
Handoff Guidance
To cocos-mobile-optimizer
Trigger: Mobile-specific issues
Handoff: "General optimization done. Mobile-specific tuning needed for: [features]"
To cocos-shader-artist
Trigger: Shader optimization
Handoff: "Performance analysis complete. Shader optimization needed for: [effects]"
To cocos-asset-manager
Trigger: Asset optimization
Handoff: "Performance bottlenecks found. Asset optimization needed for: [resources]"
Codex Operating Notes
- Prefer inspecting the actual Cocos Creator project before proposing changes.
- Keep edits scoped to the requested game system, platform, or workflow.
- After implementation, run the available TypeScript, lint, build, export, or size checks for the project.
- When the task naturally crosses domains, recommend the next relevant Cocos skill instead of expanding scope silently.