-
Notifications
You must be signed in to change notification settings - Fork 0
今後の方針
RedRimmedBox edited this page Feb 21, 2024
·
5 revisions
Version 1 時点では、Widget のレイアウトはモディファイアで行ないます(例えば .position(_:)
とか, .size(_:)
とか)。ゲーム向けの UI は、柔軟性が非常に高くていいかもしれませんが、じつはこの「柔軟性」はある意味不要とも言えます。なぜなら、ゲームの要素として UI を生成する場合、node()
などで生成された SKNode
インスタンスを操作すれば、柔軟性としては十分であるからです。
// version 1 時点での API
let display = Display()
.place {
Button(.init("Sample"))
.modifieable
.position(CGPoint(x: 0, y: 500))
Button(.init("Sample2"))
.modifieable
.position(CGPoint(x: 0, y: -500))
}
// 1つの UI を単体で生成
let button = Button(.init("Sample")).node() // .createModels() もあるよ
button.position = CGPoint(x: 0, y: 500)
Version 2 開発中の現在、自動レイアウト機能についての discussion を開始しました。これは SwiftUI にあるような、HStack
VStack
のようなレイアウトツールを取り入れ、.position(_:)
とか, .size(_:)
とかを書かなくても UI のフレームを確定できる、という機能です。
// version 2 開発現在に考案中の API
let display = Display()
.place {
HStack {
Button(.init("Sample"))
Button(.init("Sample2"))
}
}
// 1つの UI を単体で生成ももちろんできる
let (button, _) = Button(.init("Sample")).createModels() // node() は廃止するかも?
button.position = CGPoint(x: 0, y: 500)
実装は version 3 以降になるかもしれません。