一键导入
spritekit-game
SpriteKit 2D game development: SpriteView integration, scene architecture, entity-component system, physics, game loop. Use when building 2D games.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
SpriteKit 2D game development: SpriteView integration, scene architecture, entity-component system, physics, game loop. Use when building 2D games.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
App Clip implementation: separate target, associated domains, URL handling, size limits. Use when implementing app features related to app clips.
Live Activities: ActivityKit, Dynamic Island, Lock Screen widgets, push updates. Use when implementing app features related to live activities.
Safari web extension: content scripts, background scripts, native messaging. Use when implementing app features related to safari extensions.
Share extension: NSExtensionActivationRule, data handling, UI. Use when implementing app features related to share extensions.
Post-build visual UI/UX review: capture simulator screenshots, evaluate with vision, collect findings, fix issues sequentially. Use after successful builds to ensure visual quality.
Handle user-pasted images: install as app icons, add to asset catalogs as named image sets, or use as design references. Use when the user attaches images.
| name | spritekit-game |
| description | SpriteKit 2D game development: SpriteView integration, scene architecture, entity-component system, physics, game loop. Use when building 2D games. |
SpriteView is the bridge between SwiftUI and SpriteKit. It embeds an SKScene inside a SwiftUI view hierarchy.
import SpriteKit
import SwiftUI
struct GameView: View {
var body: some View {
SpriteView(scene: GameScene(size: CGSize(width: 390, height: 844)))
.ignoresSafeArea()
}
}
Key rules:
SpriteView per game screen — it owns and manages the SKScene lifecycleSpriteView(scene:, transition:, isPaused:, preferredFramesPerSecond:, options:, debugOptions:) for full control@Observable game state objectsEvery game scene uses a layer-based node hierarchy:
SKScene (GameScene)
├── backgroundLayer (SKNode) — z: -100, parallax backgrounds, sky
├── gameplayLayer (SKNode) — z: 0, player, enemies, items, platforms
└── hudLayer (SKNode) — z: 100, score, health bars, controls
Rules:
didMove(to:), add all game objects as children of the appropriate layerzPosition on layers, not on individual spritesSKCameraNode to the gameplay layer, set scene.cameraSKTransition for moving between scenesUse GKEntity + GKComponent for game object composition:
import GameplayKit
class PlayerEntity: GKEntity {
init(spriteNode: SKSpriteNode) {
super.init()
addComponent(SpriteComponent(node: spriteNode))
addComponent(HealthComponent(maxHealth: 100))
addComponent(MovementComponent(speed: 200))
}
}
Rules:
SKPhysicsBody with category bitmasks for collision detection:
struct PhysicsCategory {
static let player: UInt32 = 0x1 << 0
static let enemy: UInt32 = 0x1 << 1
static let item: UInt32 = 0x1 << 2
static let ground: UInt32 = 0x1 << 3
}
Rules:
categoryBitMask, contactTestBitMask, collisionBitMask on every physics bodySKPhysicsContactDelegate on the scene for contact callbacksphysicsWorld.gravity for platformers, set to .zero for top-down gamesThe update cycle runs every frame via update(_:):
override func update(_ currentTime: TimeInterval) {
let dt = currentTime - lastUpdateTime
lastUpdateTime = currentTime
componentSystem.update(deltaTime: dt)
}
Rules:
update() for game logic, didEvaluateActions() for post-action cleanupdidSimulatePhysics() for post-physics position correctionsDetailed references are available for each subsystem: