Skip to content

Fixing Issue with .bounds conflicting with new SKNode class - #48

Open
mpoul1 wants to merge 2 commits into
mfessenden:masterfrom
mpoul1:master
Open

Fixing Issue with .bounds conflicting with new SKNode class#48
mpoul1 wants to merge 2 commits into
mfessenden:masterfrom
mpoul1:master

Conversation

@mpoul1

@mpoul1 mpoul1 commented Nov 10, 2025

Copy link
Copy Markdown

Pull Request: Rename bounds to mapBounds & Fix Camera Description Usage of View Bounds

Summary

This PR addresses naming conflicts and clarity issues related to the term bounds in SKTilemap and SKTiledSceneCamera. The changes:

  1. Renames the public SKTilemap property formerly documented as bounds to mapBounds (property already existed internally, table docs updated).
  2. Updates camera description & debugDescription in SKTiledSceneCamera to reference the stored viewBounds instead of an implicit bounds symbol, ensuring consistent and safe usage.
  3. Keeps API surface backward compatible at runtime (no public symbol removals; only documentation text/table updated). Deprecated aliases already exist elsewhere and were not modified.

Motivation / Rationale

  • The name bounds is strongly associated with UIView/NSView semantics and is also a property Apple may add or reference on SpriteKit nodes. Using a custom bounds label in docs risks confusion and possible future collisions.
  • mapBounds is already the internal canonical name representing the rendered map’s frame; aligning documentation improves clarity for library consumers.
  • The camera previously formatted its description using a local bounds reference which could become ambiguous after the rename. Switching to the explicit viewBounds increases maintainability.

Detailed Changes

Source Edits

  • Sources/SKTilemap.swift:
    • Documentation table row updated: | bounds | -> | mapBounds |.
    • Inline comment clarifies rename reason: avoids conflict with SpriteKit’s potential node APIs.
  • Sources/SKTiledSceneCamera.swift:
    • description & debugDescription now construct string using viewBounds.size / viewBounds.roundTo() instead of shadowing any external symbol.
    • No functional behavior change besides using the correct stored rectangle.

No Public API Breaks

  • The PR only adjusts documentation and internal property usage. No external method/property names were removed or changed from a compiled standpoint.
  • Existing user code compiling against previous versions will continue working.

Testing / Verification

  • Full test suite executed via swift test -v.
  • 31 tests passed (Color, Compression, Coordinate, Parser, Performance, Properties, Query, Tilemap, Tileset). No failures, no regressions.
  • Performance benchmarks unchanged (only doc & description logic touched).

Build Warnings (Unrelated to This PR)

The following warnings were observed during the build; they predate this PR and are not introduced by the edits:

  • Multiple "non-'@objc' property/method in extensions cannot be overridden; use 'public' instead" warnings for SKTile, SKTileObject, gameplay kit extension methods, etc.
  • Generic shadowing warning in Array2D.contains<T>(_:) (will be an error in Swift 6 language mode).
  • Retroactive conformance warning: extension CGPoint: Hashable suggests adding @retroactive.

These are potential cleanup tasks for future PRs but intentionally not included here to keep scope minimal and review focused.

Migration Notes

No migration required. For clarity in documentation or samples:

  • Replace references to tilemap.bounds with tilemap.mapBounds if any external README/guide examples exist.
  • If users extended documentation or tooling that parsed the property table, update those references.

Risk Assessment

Area Risk Mitigation
Runtime Behavior Low Logic unchanged; descriptions only.
API Compatibility Low No symbol removals. Documentation-only rename.
Downstream Tools Very Low Only affects text parsing if tools scraped docs for bounds.

Screens / Output Examples

Example new camera description format:

Camera: origin: 0, 0, size: 1024 x 768, zoom: 1.0

(Clamping / mode data appended as before.)

Follow-Up Suggestions (Optional)

  1. Address Swift 6 shadowing warning in Array2D.contains<T> by renaming inner generic (Element) or constraining directly.
  2. Replace open in extension-declared computed properties with public to silence override warnings (or move them into primary type declarations if intended for subclassing).
  3. Add @retroactive to CGPoint: Hashable or remove if no longer needed (CGPoint is Hashable in modern SDKs).
  4. Consider adding a unit test asserting mapBounds == tilemap.frame post-render.
  5. Update README / generated docs to reflect the property name to reduce confusion for newcomers.

Checklist

  • Code compiles
  • Tests pass (31/31)
  • No new warnings introduced
  • Documentation updated
  • Behavior unchanged except for improved descriptions

Request

Please review and merge to improve clarity and reduce potential future naming conflicts. Let me know if you’d prefer the follow-up warning cleanups included here; I kept scope tight for easier diff review.

Thanks!

@mpoul1 mpoul1 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed

@mpoul1

mpoul1 commented Nov 15, 2025

Copy link
Copy Markdown
Author

Hello! Just a friendly reminder that this PR is ready for review. Please let me know if you need any additional information. @mfessenden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant