All articles

Move a Collectible Without Changing Your Swift Code

Use a saved level edit to test the same jump with a different reward position.

Follow along with the downloadable Desert Ruins iOS demo. Source references in this article point to Desert Ruins iOS Demo/DesertRuins/GameScene.swift. Code excerpts use the sample’s existing types and properties.

Why small layout edits become expensive

Coin placement affects a player’s route through a jump. Testing a different height should be a small design experiment. When every coin lives in scene setup code, each experiment starts with finding and editing the right coordinate. LevelEditor puts that placement on the canvas.

Make the edit in the sample

Open Desert Ruins Workspace in LevelEditor and load Levels/DesertRuins.plist. Select the coin above the first gap, drag it higher, and save. Keep the adjacent coins in place so the difference is easy to judge on the next run.

Copy the saved resource

Run the command below from the extracted Resources folder. It copies the workspace level into the iOS project’s bundled Levels folder. Build and run in Xcode after the copy. The running game uses its bundled resource, so saving in the editor alone does not refresh it.

cp "Desert Ruins Workspace/Levels/DesertRuins.plist" "Desert Ruins iOS Demo/DesertRuins/Levels/DesertRuins.plist"

See where the coin becomes a node

In GameScene.buildPickups(), the sample iterates over data.level.coins?.coins. It resolves the image and display size, creates a sprite at the configured position, adds a coin physics category, and increments the level’s coin total. The contact handler removes a collected coin and updates the counter.

Playtest the change

Repeat the first jump using the same movement and jump timing. Check whether the new height guides the player and remains reachable. If the editor’s save is blocked by its free object limits, the full sample needs a paid editor license to save. A smaller level within those limits can exercise the same workflow.

Run and edit Desert Ruins

Where Scroller2d saves work

A coordinate in Swift sends each placement revision through the source code. Saving placement in the level lets a designer move several coins, run the same pickup logic, and compare the new route on the next build. That is useful when one timing change affects a whole trail of rewards.