嗨,我正在尝试快速在 SKVideoNode 上播放视频这是我的代码,但如果我点击 VideoSprite 它只播放一次它不播放但剂量打印“我们点击了视频”我已经搜索但可以' t 似乎找到答案感谢寻找
import SpriteKit
import AVFoundation
class GameScene: SKScene
{
var VideoSprite = SKVideoNode()
override func didMoveToView(view: SKView)
{
LoadVideo("9.mp4")
}
func LoadVideo(FileToPlay:String)
{
VideoSprite = SKVideoNode (videoFileNamed:FileToPlay)
VideoSprite.position = CGPointMake(size.width/2, size.height/2);
VideoSprite.name = "VideoSprite"
VideoSprite.zPosition = 2
addChild(VideoSprite)
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent)
{
for touch in (touches as! Set<UITouch>)
{
var touch: UITouch = touches.first as! UITouch
var location = touch.locationInNode(self)
var node = self.nodeAtPoint(location)
if (node.name == "VideoSprite")
{
println("we Clicked the video")
VideoSprite.play()
}
}
}
}