April 2015
Intermediate to advanced
556 pages
17h 47m
English
Open DieView.swift and jump to drawDieWithSize(_:). Add the following code below the block that draws the die dots. The new code will run if intValue is not in the range 1...6.
if intValue == 6 {
drawDot(0, 0.5) // Mid left/right
drawDot(1, 0.5)
}
}
else {
var paraStyle = NSParagraphStyle.defaultParagraphStyle().mutableCopy()
as! NSMutableParagraphStyle
paraStyle.alignment = .CenterTextAlignment
let font = NSFont.systemFontOfSize(edgeLength * 0.5)
let attrs = [
NSForegroundColorAttributeName: NSColor.blackColor(),
NSFontAttributeName: font,
NSParagraphStyleAttributeName: paraStyle ]
let string = "\(intValue)" as NSString
string.drawInRect(dieFrame, withAttributes: attrs)
}
}
}
Run the program and try typing ...
Read now
Unlock full access