Tag: 雪碧套件

双击spriteKit中的联系人通知

当我的SKSpriteNode命中与worldCategory有联系时,我似乎得到了一个双重通知,这是怎么回事? 这会产生问题,当我想要触摸worldCategory时,因为行动正在触发运行一个行动 这是我在InitWithSize方法中的位掩码 mover.physicsBody.categoryBitMask = birdCategory; bottom.physicsBody.categoryBitMask = worldCategory; mover.physicsBody.contactTestBitMask = worldCategory; 这里是联系方式: – (void)didBeginContact:(SKPhysicsContact *)contact { if (contact.bodyA.categoryBitMask == worldCategory) { mover.texture = [SKTexture textureWithImageNamed:@"birddead1"]; NSLog(@"Contact"); self.scene.paused = YES; [pauseButton removeFromSuperview]; } } 在我的日志中显示两行“联系”

iOS实际设备在节点上运行时获取EXC_BAD_ACCESS

– (IBAction)rotateGesture:(UIRotationGestureRecognizer*)sender { SKSpriteNode * face=(SKSpriteNode*)[self.skView.scene childNodeWithName:@"face_layer"]; SKAction* action=[SKAction rotateToAngle:sender.rotation duration:0]; [face runAction:action]; } face是SKSpriteNode,它不是零(我已经testing过了)。这个方法被UIRotationGestureRecognizer调用,没有例外,但是只有在我的设备上做旋转手势时才会崩溃。 在模拟器上一切正常! (我的iPad mini2也可以,但是iPhone4没有。) 任何帮助表示赞赏! 非常感谢。

修改正在运行的SKAction的速度

我有这个代码: @implementation MyScene { SKAction *delayAction; } Inside a method: delayAction = [SKAction waitForDuration:3.0]; [self runAction:[SKAction repeatActionForever: [SKAction sequence: @[delayAction, [SKAction …]]]]] withKey:@"myKey"]; 然后我想减less加class时间。 (这种方法是更新:)所以我试过: – (void)updateVelocity { NSLog(@"duration:%f",delayAction.duration); delayAction.duration = delayAction.duration – 0.001; } 我得到: 2014-04-04 11:45:05.781 FlyFish[5409:60b] duration:1.300000 2014-04-04 11:45:05.785 FlyFish[5409:60b] duration:1.299000 2014-04-04 11:45:05.800 FlyFish[5409:60b] duration:1.298000 2014-04-04 11:45:05.816 FlyFish[5409:60b] duration:1.297000 这看起来不错,但是我的[SKAction …]在3秒后仍然继续重复。

SpriteKit暂停和恢复SKView

我想暂停和取消暂停SpriteKit中的一个场景,2个button在同一个位置。 场景运行时,我想显示“暂停”button。 场景暂停时,我想隐藏“暂停”button并显示“播放”button。 在SpriteKit中,您可以使用在SpriteKit中定义的self.scene.view.paused。 我的代码: @implementation MyScene { SKSpriteNode *PauseButton; SKSpriteNode *PlayButton; } -(id)initWithSize:(CGSize)size { if (self = [super initWithSize:size]) { [self Pause]; } return self; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { /* Called when a touch begins */ UITouch * touch = [touches anyObject]; CGPoint location = [touch locationInNode:self]; SKNode * Node = [self […]

SpriteKit生成随机curl线

我正在做一个项目,我需要完成的是产生随机curl线。 在这一点上,我已经有一个随机生成的线,但不curl。 我每0.5秒在不同的x位置产生点,并将这些点与bezier连接起来。 除了不curl之外,一切都很完美。 在下面的图片显示在1)我现在怎么拥有它和2)我想如何做到这一点。 任何想法,我可以做到这一点? 我正在使用SpriteKit – Objective C

主要Bug,在XCAssets文件夹中创build的Sprite Atlas不支持批量渲染

我开始在XCAssets文件夹中使用新的Sprite Atlas,而不是在项目文件夹中使用我的图集。 但是我注意到,当我这样做时,我的节点不再被批处理渲染,导致大量低效的绘制调用。 这完全打败了使用图集的目的! 要清楚这是我用来获得地图集的代码。 let atlas = SKTextureAtlas(named: "Sprites") “Sprites”是在XCAssets文件夹中创build的Sprite Atlas。 有没有人有解决方法,或者我坚持在项目文件夹中制作雪碧套件集合。 我正在使用Xcode 7.2testing版。 之所以我想使用新的Sprite套件集群是因为这个问题。

如何正确隐藏这些广告横幅?

(Sprite Kit Game)我希望我的广告横幅在游戏过程中被隐藏。 我已经设置了我的项目,以包含iAd和AdMob广告横幅。 在添加AdMob SDK和AdMob广告代码之前,隐藏iAd广告条时我没有任何问题。 现在有一个问题,因为我的代码是如何设置的,我似乎无法修复它: 这是代码: – (void)viewDidLoad { [super viewDidLoad]; //Add view controller as observer [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"hideAd" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:@"showAd" object:nil]; // Present the scene. [skView presentScene:scene]; self.canDisplayBannerAds = YES; appleAd = [[ADBannerView alloc] initWithFrame:CGRectZero]; appleAd.frame = CGRectOffset(appleAd.frame, 0, 0.0f); appleAd.delegate = self; //hide the apple […]

SKView和SKScene有什么区别?

从苹果文件 SKView:“一个SKView对象是一个显示Sprite Kit内容的视图,这个内容由一个SKScene对象提供。 SKSCene:“SKScene对象表示Sprite Kit中的内容场景。” 有什么不同? 一个SKScene类似于一个视图控制器和一个SKView就像一个UIView?

SKShapeNode – animation颜色的变化

我正在使用SpriteKit进行游戏。 我正在用SKShapeNode绘制一个形状。 现在我想animation它的颜色变化,但SKActions不适用于SKShapeNode。 有没有办法做到这一点,或者我必须使用不同的方法? 谢谢。 编辑: 感谢LearnCocos2D,我能够想出这个快速(而且完全不完美)的解决scheme。 int groundChangeInterval = 5; SKColor *originalColor = [SKColor colorWithRed:0.92 green:0.87 blue:0.38 alpha:1.0]; SKColor *finalColor = [SKColor colorWithRed:0.29 green:0.89 blue:0.31 alpha:1.0]; CGFloat red1 = 0.0, green1 = 0.0, blue1 = 0.0, alpha1 = 0.0; [originalColor getRed:&red1 green:&green1 blue:&blue1 alpha:&alpha1]; CGFloat red2 = 0.0, green2 = 0.0, blue2 = 0.0, […]

从SKShapeNode创build一个SKTexture

有没有办法从SKShapeNode创build一个SKTexture? 形状节点已知会导致内存问题,我正在寻找一种方法来创build一个静态graphics(.png最好)。