I am developing an app that contains a SpriteKit scene embedded inside a SwiftUI context.I am trying to render a simple SKShapeNode like this:import Foundation
import SpriteKit
class UIConnection: SKShapeNode {
override init() {
super.init()
self.fillColor = UIColor.clear
self.strokeColor = UIColor.blue
self.lineWidth = 0.01
}
func updatePositions(node1 : CGPoint, node2 : CGPoint) {
let path = CGMutablePath()
path.move(to: node1)
path.addLine(to: CGPoint(x: node1.x, y: node2.y))
path.addLine(to: CGPoint(x: node2.x, y: node2.y))
path.addLine(to: CGPoint(x: node2.x, y: node1.y))
path.addLine(to: node1)
self.path = path
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}When I am adding that Node inside the standard SpriteKit game project template in XCode (without any SwiftUI things), everything is working fine, I get a non-filled rectangle with a blue outline. The frame.width and frame.height variables are valid pixel dimensions like 750 x 1334.let node = UIConnection()
self.addChild(node)
node.updatePositions(node1: CGPoint(x: frame.midX-frame.width/4, y: frame.midY-frame.height/4), node2: CGPoint(x: frame.midX+frame.width/4, y: frame.midY+frame.height/4))Now I want to embed the SKScene inside a SwiftUI context using this approach:https://dev.to/sgchipman/using-spritekit-with-swiftui-ibcFirst thing I encounter is the fact that frame.width and frame.height both result in a value of 1.Adding the above node to the embedded SKScene results in an extremely blurred rectangle, so no solid line but some weird cloudy object.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hello!
I am thinking about creating a macOS app that requires one or multiple touch interfaces.
Apart from using Wifi - is there something high- or low-level available to enable communication (RPC or TCP/UDP) directly via the wired connection?
I found https://github.com/jensmeder/DarkLightning - would this be the right thing?
Hello!
I am struggling with the most basic things :-(
I created a Swift Package with the wizard and left it basically untouched, only added a func:
public struct TestPackage {
public init() {
}
public static func hello()
{
print("Hello, World!")
}
}
It just build fine.
Now I created a second project, this time a SpriteKit iOS app.
In the file list on the left, right-clicked on "Packages" -> "Add Packages ..." -> "Add Local" and selected the root directory of TestPackage (containing the Package.swift)
The Package now correctly appears in the "Packages" folder.
Opening a random Swift file in said SpriteKit iOS app, I expect to be able to
import TestPackage
But it tells me "No such module TestPackage".
Searching the internet, I somewhere read that I have to add the package also to the "Frameworks, Libraries and Embedded Content" section in the project's target settings, but I can't.
Hitting the "+" button there does not give me my library in the list of suggested libraries. Via "Add Other" -> "Add package dependency" -> "Add Local ..." I can again select the root directory of my library, but other than showing up twice in the left-side folder view (and not in said Frameworks, Libraries and Embedded content", I have no luck in importing it to my code.
What am I doing wrong?