我在SpriteKit中玩了一下,並且試圖讓棒圖運行。由於我缺乏經驗,我相信我已經以非常規的方式開始了這個過程。在Sprite Kit中運行棒圖動畫
我沒有畫出每個單獨的動作幀,而是加載了棒圖的單獨圖像(即頭部,膝蓋,大腿,身體,手臂等),並讓他們相應地移動。到目前爲止,除了跑步過程中膝蓋的運動和旋轉以外,所有東西都可以相互融合。
我的問題是這樣的:
當大腿拉回到它的步幅,膝蓋變得分離,並遵循直線步幅的結束而轉動。
我的問題是這樣的:
是否有連接節點大腿到小腿節點的方式,因爲如果他們在每說一個「拐點」連接,而在運動?還是有一些更有效的方法?
這是我的代碼的片段,它可能比我一直描述更多一點。
func thigh_run(){
//running config
//DONT CHANGE!
var thigh_rotation = CGFloat(M_PI)*0.8
//Can Change :)
var run_speed = NSTimeInterval(0.25)
// reset the action sequence... basically
let pos_nuetralize = SKAction.rotateByAngle(thigh_rotation/2, duration: run_speed)
let neg_nuetralize = SKAction.rotateByAngle(-thigh_rotation/2, duration: run_speed)
//strides
let thigh_pull = SKAction.rotateByAngle(-thigh_rotation, duration: run_speed*2)
let thigh_stride = SKAction.rotateByAngle(thigh_rotation/2, duration: run_speed)
// for the opposite leg
let b_thigh_pull = SKAction.rotateByAngle(-thigh_rotation/2, duration: run_speed)
let b_thigh_stride = SKAction.rotateByAngle(thigh_rotation, duration: run_speed*2)
//knee movement
let stride = SKAction.sequence([thigh_stride, thigh_pull, pos_nuetralize])
let pull = SKAction.sequence([b_thigh_pull, b_thigh_stride, neg_nuetralize])
r_arm.runAction(SKAction.repeatActionForever(stride))
f_leg_thigh.runAction(SKAction.repeatActionForever(stride))
b_leg_thigh.runAction(SKAction.repeatActionForever(pull))
//knee_run(run_speed)
}
func knee_run(speed: NSTimeInterval){
let knee_stride = SKAction.moveTo(CGPointMake(f_leg_thigh.position.x+f_leg_thigh.size.height, f_leg_thigh.position.y), duration: speed)
let knee_reset = SKAction.moveTo(CGPointMake(f_leg_thigh.position.x, f_leg_thigh.position.y-f_leg_thigh.size.height), duration: speed)
let knee_pull_rotate = SKAction.rotateToAngle(CGFloat(M_PI)/2, duration: speed, shortestUnitArc: true)
let knee_pull_rotate_half = SKAction.rotateToAngle(CGFloat(M_PI)*2, duration: speed, shortestUnitArc: true)
let knee_pull_half = SKAction.moveTo(CGPointMake(f_leg_thigh.position.x-f_leg_thigh.size.height, f_leg_thigh.position.y/2), duration: speed)
let knee_pull = SKAction.moveTo(CGPointMake(f_leg_thigh.position.x-f_leg_thigh.size.height, f_leg_thigh.position.y), duration: speed)
//Grouping of the knee moving and rotating at the same time
let knee_pull_group_half = SKAction.group([knee_pull_half, knee_pull_rotate_half])
let knee_pull_group = SKAction.group([knee_pull, knee_pull_rotate])
let f_knee_stride_seq = SKAction.sequence([knee_stride,knee_reset,knee_pull,knee_reset])
let f_knee_pull_seq = SKAction.sequence([knee_pull_group_half, knee_reset, knee_stride, knee_reset])
f_leg_calf.runAction(SKAction.repeatActionForever(f_knee_stride_seq))
b_leg_calf.runAction(SKAction.repeatActionForever(f_knee_pull_seq))
}
我知道這可能很難閱讀,我已經記錄了它爲自己很好。 f_前綴用於「前」支線,而b用於「後」_leg。但將其視爲右腿和左腿。
反正!提前致謝!我感謝任何幫助或提示!評論任何進一步的解釋! :)
你可以發佈一個動畫實現的gif? – ZeMoon 2015-03-31 05:35:47