大佬教程收集整理的这篇文章主要介绍了Swift Sprite Kit开始触摸功能,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
import SpriteKit class GameScene: SKScene { //Rectangle Skeletions var leftWallRect = CGRect(x: 0,y: 0,width: 40,height: 1000) var ball = SKShapeNode(circLeofRadius: 25); override func didMoveToView(view: SKView) { // Declare the Sprites in your scene var ball = SKShapeNode(circLeofRadius: 25); let leftWall = SKShapeNode(rect: leftWallRect); let rightWall = SKShapeNode(rect: leftWallRect); let pin = SKSpriteNode(imagenamed: "pin"); // Ball Properties ball.strokeColor = UIColor.blackColor() ball.fillColor = UIColor.redColor() ball.position = CGPointMake(self.frame.width / 2,self.frame.height / 4 - 100 ) self.addChild(ball) // Left Wall Properties leftWall.fillColor = UIColor.purpleColor() leftWall.strokeColor = UIColor.blackColor() leftWall.position = CGPointMake(self.frame.size.width / 3 - 45,self.frame.size.height / 2 - 400) self.addChild(leftWall) //Right Wall Properties rightWall.fillColor = UIColor.purpleColor() rightWall.strokeColor = UIColor.blackColor() rightWall.position = CGPointMake(self.frame.size.width / 2 + 175,self.frame.size.height / 2 - 400) self.addChild(rightWall) } override func touchesBegan(touches: Set<NSObject>,withEvent event: UIEvent) { /* Called when a touch begins */ let touch = touches.first as! UITouch let touchLOCATIOn = touch.LOCATIOnInNode(self) if touchLOCATIOn == ball.position{ ball.position = touchLOCATIOn println("Touches"); } } override func update(currentTime: CFTimeInterval) { /* Called before each frame is rendered */ } }
以上是大佬教程为你收集整理的Swift Sprite Kit开始触摸功能全部内容,希望文章能够帮你解决Swift Sprite Kit开始触摸功能所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。