###前提・実現したいこと
プログラム初心者です。
swiftにてiphoneアプリを作成しています。
音ゲーを作りたいのですが
音に合わせて譜面を落とす仕組みがわかりません。。
いろいろ調べましたが、swiftのサンプルや
譜面をどうするかなど書いているサイト、書籍がなく
困っています。
サンプルコードも合わせてご回答いただけますと幸いです。
###該当のソースコード
現在ランダムに落下させている状況です。
_timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self,
selector: "addMeteolength", userInfo: nil, repeats: true)
//石の追加
func addMeteolength() {
let meteo = SKSpriteNode(imageNamed: "dan.png")
// meteo.position = CGPointMake(CGFloat(20+rand(320)), 640)
meteo.position = CGPoint(
x: CGFloat(rand(UInt32(self.size.width))),
y: CGFloat(rand(UInt32(self.size.height)))
)
meteoLayer.addChild(meteo)
meteo.runAction(SKAction.moveToY(0, duration: 7))
}
//乱数の取得
func rand (num: UInt32) -> Int {
return Int(arc4random()%num)
}
###補足情報(言語/FW/ツール等のバージョンなど)
swift , SpriteKit
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。