mardi 4 août 2015

What is the Swift alternative of radiansToVector and randomInRange Objective-C functions?

I watched an old ios 7 spritekit course and they use these methods. I tried to use them in Swift, but they didn't work. What should I use instead?

static inline CGVector radiansToVector(CGFloat radians) {
    CGVector vector;
    vector.dx = cosf(radians);
    vector.dy = sinf(radians);
    return vector;
}

static inline CGFloat randomInRange(CGFloat low, CGFloat high) {
    CGFloat value = arc4random_uniform(UINT32_MAX) / (CGFloat)UINT32_MAX;
    return value * (high - low) + low;
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire