小编san*_*ony的帖子

iOS 7中的自定义字体

我正在开发游戏,我想在我的应用程序中使用自定义字体.我正在使用SpriteKit,如果这很重要的话.我已经尝试过使用这个https://github.com/deni2s/IBCustomFonts但我无法使用这个字体http://www.fontspace.com/freaky-fonts/emulogic

我尝试了各种各样的东西,并且我在应用程序的info.plist上注册了字体...有谁知道发生了什么?

iphone fonts ios

102
推荐指数
4
解决办法
6万
查看次数

NSPredicate查询不包含特定字符串

看这个高低,但找不到我的答案.我期待查询所有不等于指定字符串的记录的核心数据.例如,所有记录不等于当前会话ID.我试过这些无济于事:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"listingID != %@", [sitListingID objectAtIndex:i]];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ NOT CONTAINS[cd] %@",@"listingID", [sitListingID objectAtIndex:i]];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ NOT CONTAINS %@",@"listingID", [sitListingID objectAtIndex:i]];

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"listingID NOT like %@", [sitListingID objectAtIndex:i]];
Run Code Online (Sandbox Code Playgroud)

没什么用.HEEEEELP !!! -------------------------------------------------- ---更多代码

NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"ListingRecord" inManagedObjectContext:context];
    [request setEntity:entity];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"sessionID <> %@", uniqueSessionListings];
    [request setPredicate:predicate];
    NSError *error = nil;
    NSMutableArray *mutableFetchResults = [[context executeFetchRequest:request error:&error] mutableCopy];
Run Code Online (Sandbox Code Playgroud)

core-data nspredicate ios

39
推荐指数
1
解决办法
3万
查看次数

将参数传递给drawRect

我有几个UIView类都绘制相同的东西,但使用不同的颜色和alpha设置.我试图传递参数,但无法弄清楚如何获得我需要的drawRect部分.

我这样画:

CGRect positionFrame = CGRectMake(widthCoordinate,heightCoordinate,20.9f,16.5f);
DrawHexBlue *hex = [[DrawHexBlue alloc] initWithFrame:positionFrame];
[self.imageView addSubview:hex];
Run Code Online (Sandbox Code Playgroud)

我的DrawHexBlue类是这样的:

- (id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self)
{
    [self setOpaque:YES];
    [self setBackgroundColor:[UIColor clearColor]];
}
return self;
Run Code Online (Sandbox Code Playgroud)

}

- (void)drawRect:(CGRect)rect{    
UIBezierPath *aPath = [UIBezierPath bezierPath];
[[UIColor whiteColor] setStroke];
[[UIColor blueColor] setFill];

// Set the starting point of the shape.
[aPath moveToPoint:CGPointMake(7, 0)];

// Draw the lines.
[aPath addLineToPoint:CGPointMake(16.2, 0)];
[aPath addLineToPoint:CGPointMake(20.9, 8.7)];
[aPath addLineToPoint:CGPointMake(16.2, 16.5)];
[aPath addLineToPoint:CGPointMake(6.7, 16.5)];
[aPath addLineToPoint:CGPointMake(2.1, 8.7)];
[aPath closePath];

[aPath setLineWidth:1.0f]; …
Run Code Online (Sandbox Code Playgroud)

uiview drawrect ios

8
推荐指数
1
解决办法
3201
查看次数

enumerateBodiesAlongRayStart将"机会"打印到Xcode 6中的控制台

我正在使用enumerateBodiesAlongRayStart,这个方法不断地在我的控制台上打印"Chance"这个词.有没有办法压制这个?这是怎么回事?

self.gameScene.physicsWorld.enumerateBodiesAlongRayStart(self.rayStart, end: self.rayEnd, usingBlock: {
    body, point, normal, stop in

})
Run Code Online (Sandbox Code Playgroud)

loops ios sprite-kit swift

8
推荐指数
1
解决办法
557
查看次数

如何使Sprite遵循贝塞尔曲线

我是Objective-c和sprite kit的新手,但我已经做了一段时间的游戏开发.我目前正在进行2D游戏,我的敌人船只在屏幕上从右向左移动.我一直在关注游戏不同部分的教程,然后在必要时添加它.我找到了一个教程,其中游戏中的敌人遵循bezier路径并且我已经设法在我的游戏中实现这一点但是因为我是bezier曲线的新手我不完全理解它们并且算法使我的精灵从上到下移动但我需要它们从左到右.

我已经包含了我用来将贝塞尔曲线添加到我的精灵的代码片段,有关我如何让它们从右到左而不是从上到下移动的任何建议.

CGMutablePathRef cgpath = CGPathCreateMutable();

        float xStart = [self getRandomNumberBetween:0+asteroid.size.width to:self.frame.size.width-asteroid.size.width];
        float xEnd = [self getRandomNumberBetween:0+asteroid.size.width to:self.frame.size.width-asteroid.size.width];
        float cp1X =[self getRandomNumberBetween:0+asteroid.size.width to:self.frame.size.width-asteroid.size.width];
        float cp1y = [self getRandomNumberBetween:0+asteroid.size.width to:self.frame.size.width-asteroid.size.height];
        float cp2x = [self getRandomNumberBetween:0+asteroid.size.width to:self.frame.size.width-asteroid.size.width];
        float cp2Y = [self getRandomNumberBetween:0 to:cp1y];

        CGPoint s = CGPointMake(xStart, 1024.0);
        CGPoint e = CGPointMake(xEnd, -100);
        CGPoint cp1 = CGPointMake(cp1X, cp1y);
        CGPoint cp2 = CGPointMake(cp2x, cp2Y);
        CGPathMoveToPoint(cgpath, NULL, s.x, s.y);
        CGPathAddCurveToPoint(cgpath, NULL, cp1.x, cp1.y, cp2.x, cp2.y, e.x, e.y);

        SKAction *enemyCurve = [SKAction followPath:cgpath asOffset:NO …
Run Code Online (Sandbox Code Playgroud)

bezier 2d-games sprite-kit

8
推荐指数
1
解决办法
2240
查看次数

iOS - 基于设备的不同图像或缩放相同的图像?

开发人员似乎总是为不同的设备创建不同的图像资源,并根据设备加载它们.但是,为最大分辨率设备(iPad)创建图像然后为iPhone 6,5等缩小图像是否有任何缺点?

我使用SpriteKit,所以我只创建不同大小的SKSpriteNodes并对它们应用相同的纹理并缩放它以适应节点.

我知道性能可以考虑(为旧设备加载大图像).但除此之外,还有什么吗?这些图像会出现像素化/模糊吗?

iphone image ios sprite-kit

8
推荐指数
1
解决办法
1900
查看次数

SKLightNode投射阴影问题

我没有成功地让SKSpriteNode投射阴影,并且在从同一光源进入阴影时也会消失.我可以做到两个中的一个但不是两个.

根据文档:如果精灵位于由光投射的阴影内并且精灵的z位置低于光,则阴影会影响精灵的点亮方式.我所做的一切.我的SKLightNode的zPosition为100,所有其他节点的zPosition都较低.

我已经尝试了lightingBitMask,shadowCastBitMask和shadowedBitMask的任何和所有设置组合,但没有任何效果.

我发布了孤立的代码,重现了我的问题.蓝色的盒子投下阴影但没有被墙影覆盖.紫色的盒子没有阴影,被墙影覆盖.

灯光响应触摸运动,因此可以随意在屏幕上移动.该项目处于横向模式.

我错过了什么或没看到什么?

#import "GameScene.h"

@implementation GameScene {
    SKSpriteNode *lightBulb;
}

-(void)didMoveToView:(SKView *)view {

    typedef NS_OPTIONS(uint32_t, Level1LightCategory)
    {
        CategoryLightPlayer            = 1 << 0,
    };

    SKSpriteNode *worldNode = [SKSpriteNode spriteNodeWithColor:[SKColor clearColor] size:CGSizeMake(1136, 640)];
    worldNode.zPosition = 10;
    //worldNode.position = CGPointMake(self.size.width/2, self.size.height/2);
    [self addChild:worldNode];

    lightBulb = [SKSpriteNode spriteNodeWithColor:[SKColor yellowColor] size:CGSizeMake(20, 20)];
    lightBulb.zPosition = 100;
    lightBulb.position = CGPointMake(50, 50);
    [worldNode addChild:lightBulb];

    SKLightNode *light = [[SKLightNode alloc] init];
    //light.zPosition = 100; // <- tried setting this again but to no …
Run Code Online (Sandbox Code Playgroud)

shadow sprite-kit skspritenode sklightnode

7
推荐指数
1
解决办法
1795
查看次数

浮动泡沫像游戏中心主屏幕

试图找到类似的答案但不满意.我想在通知中心的主屏幕上像浮动气泡中做一些按钮.我猜苹果UIKitDynamic用来产生一些效果却找不到合适的路径.

他们使用Quartz Core还是使用Core Animation框架?

我知道这可能是一个愚蠢的问题,但在这个网站上没有人问...(我猜)

非常感谢.

Ciao ciao :)

game-center ios7

5
推荐指数
1
解决办法
898
查看次数

如何在 SpriteKit (Swift) 中使用平移和捏合缩放手势?

我刚刚开始使用 SpriteKit。这是我的 GameScene.swift 文件。我的目标是能够通过捏合来缩放和平移场景,但我不知道如何开始。

import SpriteKit

class GameScene: SKScene {
override func didMoveToView(view: SKView) {

    /* Setup your scene here */
    var circle1 = SKShapeNode(circleOfRadius: 50.0)
    circle1.position = CGPointMake(400, 600)
    circle1.name = "1"
    circle1.fillColor = SKColor.yellowColor()
    circle1.strokeColor = SKColor.yellowColor()
    self.addChild(circle1)

    var circle2 = SKShapeNode(circleOfRadius: 50.0)
    circle2.position = CGPointMake(600, 400)
    circle2.name = "2"
    circle2.fillColor = SKColor.redColor()
    circle2.strokeColor = SKColor.redColor()
    self.addChild(circle2)
}

override func update(currentTime: CFTimeInterval) {
    /* Called before each frame is rendered */
}
}
Run Code Online (Sandbox Code Playgroud)

我使用的是 Xcode 6.3。

ios sprite-kit swift

5
推荐指数
1
解决办法
1263
查看次数

将SKSpriteNode屏蔽为液体

我想创造一种液体动力学.我搜索了很多,创造了随着设备运动移动的球,但我不知道如何使球看起来像液体..我猜它是一些面具,但我没有找到怎么做.有人可以帮助我吗?谢谢.

calayer ios sprite-kit skphysicsbody

4
推荐指数
1
解决办法
736
查看次数