Tag: 精灵套件

SpriteKit崩溃与std :: out_of_range:vector问题

所以我正在试图确定这次事故的原因是什么。 请看这里的崩溃报告: 这是在日志中产生的:libc ++ abi.dylib:以std :: out_of_range:vectortypes的未捕获exception 基本上,崩溃不会一直发生,似乎在更新的iOS设备上发生。 如果我清理我的构build,我已经注意到它发生的可能性要小得多。 我假设它可能与我的纹理地图集有关系? 有没有人有这个相同的问题,你做了什么来解决? 需要指出正确的方向在这里做了一段时间的尝试和错误,而不是所有的纹理负载,但一直没能find它。 提前致谢! 编辑: -(void)load_engine { //general atlases circle_explodes_atlas = [SKTextureAtlas atlasNamed:@"effect_circle_explode"]; box_explodes_atlas = [SKTextureAtlas atlasNamed:@"box_explodes"]; fence_atlas = [SKTextureAtlas atlasNamed:@"fence_new"]; swipe_atlas = [SKTextureAtlas atlasNamed:@"swipe"]; coin_atlas = [SKTextureAtlas atlasNamed:@"coin"]; reward2x_atlas = [SKTextureAtlas atlasNamed:@"two_times"]; reward3x_atlas = [SKTextureAtlas atlasNamed:@"three_times"]; healthpack_atlas = [SKTextureAtlas atlasNamed:@"healthpack_explodes"]; effects_atlas = [SKTextureAtlas atlasNamed:@"effect"]; //character […]

SKAction.moveToX重复值更改

我希望能够移动球,每隔20像素移动一次我试过这个球,但是什么也没做,球停留在开始的地方,它不移动到屏幕的尽头,我知道我没有不要把waitForDuration,因为我想检查它是否会移动或不 func spwan() { let ball:SKSpriteNode = SKScene(fileNamed: "Ball")?.childNodeWithName("ball") as! SKSpriteNode ball.removeFromParent() self.addChild(ball) ball.name = "spriteToTrack" ball.zPosition = 0 ball.position = CGPointMake(1950, 1000) var num:CGFloat = ball.position.x let a1 = SKAction.moveToX(num – 20, duration: 10) // i want to get to -50 let a1 = SKAction.moveToX(-50 , duration: 10) let minus = SKAction.runBlock{ num -= […]

Xcode 7:'supportedInterfaceOrientations'实现中的返回types冲突:'UIInterfaceOrientationMask'vs'NSUInteger'

我只是更新了我的Xcode到版本7.0(7A220),不幸的是,我有几个问题。 让我列出这些: 现在这些images.xcassets 仅支持1x,2x,3x。 视网膜4 2x盒子仍然存在现有的图像,但你不能添加视网膜支持新的设置。 我该如何处理? 我的应用程序不再适用于iPhone 4 *和5 *。 图像消失:我只能看到文字(实际上只有启动屏幕图像的作品)。 我猜想,我可能有问题的iPhone 5 *(不再支持Retina 4),但我很惊讶iPhone 4 *(我曾经创build每个图像-480版本,并放在2x框内)。 这里同样的问题:我该如何处理? 我有几个警告:第一个是关于“更新到推荐的项目设置”(完成,但没有改变)。 第二个是在运行期间: ../ViewController.m:41:1: Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned int') 第三个也在运行时: (null): Directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks' 有人能帮我吗 ? 我使用Xcode 7.0(7A220)和SpriteKit来开发我的应用程序。

如何使一个物体粘在SpriteKit中的另一个移动物体上

我有一个物体沿X轴移动,而另一个身体rest。 在发生碰撞后,我希望静止物体和运动物体一起移动。 我使用这个代码来移动第一个主体: SKAction* moveBlock = [SKAction moveByX:-distanceToMove y:0 duration:0.01 * distanceToMove]; SKAction* removeBlock = [SKAction removeFromParent]; _moveBlocksAndRemove = [SKAction sequence:@[moveBlock, removeBlock]]; 而在碰撞检测中我试图设置一个摩擦: if (firstBody.categoryBitMask == categoryA && secondBody.categoryBitMask == categoryB) { firstBody.friction = 1.0; secondBody.friction = 1.0; } 但是这没有用。 由于速度= 0,所以第一个物体的速度不起作用; 有任何想法吗?

迅速 – 随着时间的推移增加对象的速度

我正在寻找一种方法来增加我玩游戏的速度,我希望通过增加一定时间之后,即每隔30秒或最好在10个物体(树)之后产生的障碍物的频率,已经产生了,所以玩得越久,玩得越久。 这是我目前的设置,我使用repeatActionForever我怎么能改变这个像repeatAction10Times与每个循环不同的延迟variables? //in didMoveToView treeTexture1 = SKTexture(imageNamed: "tree") treeTexture1.filteringMode = SKTextureFilteringMode.Nearest var distanceToMove = CGFloat(self.frame.size.width + 0.1); var moveTrees = SKAction.moveByX(-distanceToMove, y:0, duration:NSTimeInterval(0.006 * distanceToMove)); var removeTrees = SKAction.removeFromParent(); moveAndRemoveTrees = SKAction.sequence([moveTrees, removeTrees]); var spawn = SKAction.runBlock({() in self.spawnTrees()}) //this delay is what I would like to alter for each loop var delay = SKAction.waitForDuration(NSTimeInterval(1.2)) […]

将切片转换为XCode Swift中的精灵节点

我正在开发一个迷你游戏,并使用Tiled程序绘制了地图。 假设我使用了三张图片的一组图片; 我如何将它们“转换”为SKSpriteNodes? 假设有一个瓦片表示字符,三个瓦片表示地面。 我希望这四个是精灵节点。 提前致谢

如何使用arc4random从数组中select一个随机的SKShapeNode?

我正在尝试使用sprite工具包和swift来制作我的第一个应用程序。 我创build了一个数组并填充了两个形状节点(如下所示。 //name the properties for enemy 1 enemy1 = SKShapeNode (rectOfSize: CGSize(width: rectWidth/10, height: rectHeight/10)) enemy1.position = first enemy1.fillColor = UIColor.blackColor() enemy1.physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: rectWidth, height: rectHeight)) enemy1.physicsBody?.dynamic = true enemy1.physicsBody?.affectedByGravity = false //name the properties for enemy 2 enemy2 = SKShapeNode (rectOfSize: CGSize(width: rectWidth/10, height: rectHeight/10)) enemy2.position = second enemy2.fillColor = UIColor.blackColor() […]

UIView不会投射到SKView

我一直试图在我的Sprite Kit游戏中实现游戏中心,但每次我尝试呈现排行榜… -(void)showLeaderboard:(UIViewController*)gcvc { GKGameCenterViewController *leaderboardController = [[GKGameCenterViewController alloc] init]; if (leaderboardController != NULL) { leaderboardController.leaderboardIdentifier = @"Game_Leaderboard"; leaderboardController.viewState = GKGameCenterViewControllerStateLeaderboards; leaderboardController.gameCenterDelegate = self; UIViewController *vc = self.view.window.rootViewController; [vc presentViewController: leaderboardController animated: YES completion:nil]; } } 游戏崩溃在启动时出现错误: [UIView setShowsDrawCount:]:无法识别的select器发送到实例0x178169e40(lldb) 我查了一下相关的问题,他们都提出把IB的View类改成SKView类,但是没有运气。 exception断点停在行: SKView *spriteView = (SKView *)self.view; spriteView.showsDrawCount = YES; 该视图显然是SKViewtypes,但仍然表示spriteView是UIViewtypes。 我不确定这是否应该是重要的,因为游戏的主视图控制器是UIViewController的一个子类,这是呈现Game Center排行榜所需要的,所以我不知道如何解决这个错误。

SpriteKit,Swift – ScrollView不显示

好的,所以我使用这个方法实现了一个滚动视图: 如何在spritekit中创build一个垂直滚动菜单? 现在,当我启动场景时,除黑色/灰色背景外,不显示任何内容 这里是我在菜单场景中使用的代码: import Foundation import SpriteKit import UIKit //let kMargin: CGFloat = 40 //var backButton = SKSpriteNode() //var selectButton = SKSpriteNode() var moveableNode = SKNode() var scrollView: CustomScrollView! private var imageSize = CGSize.zero var sprite = SKSpriteNode() class Menu: SKScene { func didMoveToView() { addChild(moveableNode) scrollView = CustomScrollView(frame: CGRect(x: 0, y: 0, width: […]

在Swift for iOS 7.1中解压.sks文件

我有一个应用程序,它使用以下扩展名从iOS 8中的.sks文件很好地加载: class func unarchiveFromFile(file : NSString) -> SKNode? { if let path = NSBundle.mainBundle().pathForResource(file as String, ofType: "sks") { var sceneData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil)! var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData) archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene") let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! GameScene archiver.finishDecoding() return scene } else { return nil } } 但是,当我在运行iOS 7.1的设备上使用它时,我在AppDelegate上获得了一个EXC_BAD_ACCESS代码EXC_I386_GPFLT,并在日志中获得了这个代码: […]