Skip to content

Commit

Permalink
Uncomment sprite draw function (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
finnvoor authored Jul 2, 2024
1 parent 3ba9508 commit 5d408f8
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions Sources/PlaydateKit/Core/Sprite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public enum Sprite {
let sprite = unsafeBitCast(userdata, to: Sprite.self)
sprite.update()
}
// setDrawFunction { sprite, bounds, drawRect in
// let userdata = PlaydateKit.Sprite.getUserdata(sprite.unsafelyUnwrapped).unsafelyUnwrapped
// let sprite = unsafeBitCast(userdata, to: Sprite.self)
// sprite.draw(bounds: Rect(bounds), drawRect: Rect(drawRect))
// }
setDrawFunction { sprite, bounds, drawRect in
let userdata = PlaydateKit.Sprite.getUserdata(sprite.unsafelyUnwrapped).unsafelyUnwrapped
let sprite = unsafeBitCast(userdata, to: Sprite.self)
sprite.draw(bounds: Rect(bounds), drawRect: Rect(drawRect))
}
setCollisionResponseFunction { sprite, other in
let spriteUserdata = PlaydateKit.Sprite.getUserdata(sprite.unsafelyUnwrapped)
let sprite = unsafeBitCast(spriteUserdata, to: Sprite.self)
Expand All @@ -42,11 +42,11 @@ public enum Sprite {
let sprite = unsafeBitCast(userdata, to: Sprite.self)
sprite.update()
}
// setDrawFunction { sprite, bounds, drawRect in
// let userdata = PlaydateKit.Sprite.getUserdata(sprite.unsafelyUnwrapped).unsafelyUnwrapped
// let sprite = unsafeBitCast(userdata, to: Sprite.self)
// sprite.draw(bounds: Rect(bounds), drawRect: Rect(drawRect))
// }
setDrawFunction { sprite, bounds, drawRect in
let userdata = PlaydateKit.Sprite.getUserdata(sprite.unsafelyUnwrapped).unsafelyUnwrapped
let sprite = unsafeBitCast(userdata, to: Sprite.self)
sprite.draw(bounds: Rect(bounds), drawRect: Rect(drawRect))
}
setCollisionResponseFunction { sprite, other in
let spriteUserdata = PlaydateKit.Sprite.getUserdata(sprite.unsafelyUnwrapped)
let sprite = unsafeBitCast(spriteUserdata, to: Sprite.self)
Expand All @@ -66,8 +66,7 @@ public enum Sprite {

/// If the sprite doesn’t have an image, the sprite’s draw function is called as needed to update the display. Note that this method
/// is only called when the sprite is on screen and has a size specified via ``setSize(width:height:)`` or ``bounds``.
/// > Warning: This currently does not work due to [apple/swift/issues/72626](https://github.com/apple/swift/issues/72626)
@available(*, unavailable) open func draw(bounds _: Rect<Float>, drawRect _: Rect<Float>) {}
open func draw(bounds _: Rect<Float>, drawRect _: Rect<Float>) {}

/// Override to control the type of collision response that should happen when a collision with other occurs.
///
Expand Down

0 comments on commit 5d408f8

Please sign in to comment.