Tag: 精灵套件

将自定义“数字”图像添加到SKLabelNode中,作为使用Swift的SpriteKit分数

我基本上想要在单曲中添加自定义字体编号(与图像),并添加他们为我的比赛与SpriteKit我的比分。 这是字体图像风格 他们是从0到9的数字 我一直在试图弄清楚这一点。 我不确定是否可以将它添加到SKLabelNode中,或者是否需要在课堂上完成。

雪碧套件纹理行事有趣

好吧,这个让我尖叫到墙上…所以请忍受我。 我开始使用Xcode中的SpriteKit模板编写一个简单的游戏。 我将两个PNG添加到名为Stage01.atlas的文件夹中,并将Stage01.atlas拖到项目中。 不记得我select了哪个选项,因为它在项目导航器中显示为蓝色的文件夹图标(可能是因为它有扩展名?)。 接下来,我使用实例化了几个精灵 [[SKSpriteNode alloc] initWithImageNamed:@"My_Image_Name_Without_The_@2x_Or_Extension"]; 起初,它不起作用,因为我忘了在构build设置中启用纹理图集。 然后,它像一个魅力,但… 接下来,我添加了第三个PNG到地图集来显示一种新的精灵。 新的精灵无处可见。 我尝试一个干净的安装:从设备上删除应用程序,清理,build立。 现在所有的精灵都呈现为一个白色的四边形,里面有一个边框和一个大的红色“X”。 我也得到了控制台消息: SKTexture: Error loading image resource: "My_Image_Name_Without_The_@2x_Or_Extension" 我尝试删除.atlas文件夹,并重新添加它作为“为任何添加的文件夹创build组”和“为所有添加的文件夹创build文件夹引用” (这可以导致资源被放置在子文件夹而不是捆绑根目录,所以它通常是UIImage等), 无济于事 。 我用这个replace了精灵创build代码: SKTexture* texture = [SKTexture textureWithImageNamed:name]; SKSpriteNode* body = [[SKSpriteNode alloc] initWithTexture:texture]; …并放置一个断点,看纹理是否nil 。 事实并非如此 。 那么,是什么给了? 附注:与模板捆绑在一起的“飞船”纹理呈现良好。 附注2:有人创build标签“spritekit”(SO不让我使用它,因为它已经存在了,但它不会作为一个build议)。

共享扩展程序不上传全尺寸图像

我正在开发我的iOS应用程序的共享扩展。 我真的做了所有的事情,但问题是,我的代码只是为小图像工作,但是当我上传从设备相机拍摄的图像,然后上传失败,只有文本得到升级。 – (void)performUploadWith:(NSDictionary *)parameters imageFile:(UIImage *)image{ NSString *boundary = @"SportuondoFormBoundary"; // NSURLSessionConfiguration *configuration= [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationName]; // NSURLSession *session=[NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil]; // NSMutableURLRequest *request;//[NSURLRequest pho] NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; configuration.HTTPAdditionalHeaders = @{ @"api-key" : @"55e76dc4bbae25b066cb", @"Accept" : @"application/json", @"Content-Type" : [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary] }; NSURLSession *session=[NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil]; NSMutableData *body = […]

有没有反转SKSpriteNode的颜色的方法

我想知道是否有可能颠倒SKSpriteNode的颜色(或调整色调)。

用SpriteKit中的touchesMoved旋转奖金轮

是否有可能使用applyAngularImpulse而不是指数级地增加车轮的速度? 理想情况下,我想让车轮沿着我的手指,但是设置node.zRotation += atan2f(y2-y1, x2-x1)我的车轮失去控制。 这就是我所定下的,但感觉非常不可思议: – (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; SKNode *node = [self nodeAtPoint:location]; CGPoint positionInScene = [touch locationInNode:self]; CGPoint previousPosition = [touch previousLocationInNode:self]; [node.physicsBody applyAngularImpulse:(previousPosition.x – positionInScene.x) * 0.1]; node.physicsBody.angularDamping = 1; } 场景: https : //dl.dropboxusercontent.com/s/gexfburjm1coude/Screen%20Shot%202014-10-21%20at%2010.30.31%20PM.png?dl = 0

如何在SpriteKit上做一个切换button

我在SpriteKit中做了一个声音切换button,我试图find一个快速的方法来做到这一点。 我记得在Cocos2d中有一个名为CCMenuItemToggle的variables,它使得所有的东西,例如: CCMenuItemToggle* musicButtonToggle = [CCMenuItemToggle itemWithItems:[NSArray arrayWithObjects:soundButtonOn,soundButtonOff, nil] block:^(id sender) { [self stopSounds]; }]; 任何人都知道在SpriteKit上做到这一点?

SKSpriteNode子类化swift

我发现了一些这方面的post,但我仍然困惑如何做到这一点。 我知道我必须使用init(texture:SKTexture!,color:UIColor!,size:CGSize)的“指定初始化程序”。 真的,我不会用那个。 我想只是添加一些属性的精灵节点。 class Piece: SKSpriteNode { enum Type: Int { case type1 = 1, type2, type3, type4, type5 } var piecetype : Type init(texture: SKTexture!, color: UIColor!, size: CGSize) { self.piecetype = .type1 super.init(texture: texture, color: color, size: size) } convenience init(imageNamed: String!, currentPiece: Type) { self.piecetype = currentPiece let color = UIColor() […]

使用自定义SKAction的EaseOut动作

我有以下自定义SKAction工作,但作为一个EaseIn而不是EaseOut。 我想要它EaseOut! 我很失败地用网上find的各种缓解方程来纠正它。 let duration = 2.0 let initialX = cameraNode.position.x let customEaseOut = SKAction.customActionWithDuration(duration, actionBlock: {node, elapsedTime in let t = Double(elapsedTime)/duration let b = Double(initialX) let c = Double(targetPoint.x) let p = t*t*t*t*t let l = b*(1-p) + c*p node.position.x = CGFloat(l) }) cameraNode.runAction(customEaseOut) 任何帮助将不胜感激。 谢谢

Swift SpriteKit edgeLoopF​​romRect问题

以下代码可以识别场景的底部和顶部边缘 ,并按预期方式弹起球。 但是,场景的左右边缘始终被破坏。 球离开屏幕,然后如果施加足够的力量,最终返回。 就好像场景的边缘超出了iphone模拟器窗口的边缘。 import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView){ self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame) backgroundColor = UIColor.cyanColor() var ball = SKSpriteNode(imageNamed: "ball") ball.position = CGPoint(x: self.size.width/2, y: self.size.height/2) self.addChild(ball) ball.physicsBody = SKPhysicsBody(circleOfRadius: ball.frame.size.height/2) let push = CGVectorMake(10, 10) ball.physicsBody.applyImpulse(push) } } 我认为这与.sks文件有关,因为尺寸是在那里设置的,如果我改变它反映在游戏上的尺寸。 任何人都知道如何使这行代码优先于.sks文件的维度? 这样它将是dynamic的,可以在不同的设备上工作。 self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame) 我在这里发现了同样的问题,但从来没有回答过: Swift物理边缘识别问题 […]

SpriteKit如何获得正确的屏幕尺寸

我试过了 self.frame.size self.view!.frame.size UIScreen.mainScreen().bounds.size 他们都没有工作。 如何获得设备的正确屏幕尺寸?