Please note, this blog entry is from a previous course. You might want to check out the current one.
Create the paddle lazily. Place it outside (just a little bit) of the game view – which perhaps a bad way to know if it has been created recently. … and make it nice and colorful, with rounded corners etc …
struct Constants {
static let PaddleSize = CGSize(width: 80.0, height: 20.0)
static let PaddleCornerRadius: CGFloat = 5.0
static let PaddleColor = UIColor.greenColor()
}
lazy var paddle: UIView = {
let paddle = UIView(frame: CGRect(origin: CGPoint(x: -1, y: -1), size: Constants.PaddleSize))
paddle.backgroundColor = Constants.PaddleColor
paddle.layer.cornerRadius = Constants.PaddleCornerRadius
paddle.layer.borderColor = UIColor.blackColor().CGColor
paddle.layer.borderWidth = 2.0
paddle.layer.shadowOffset = CGSize(width: 2.0, height: 2.0)
paddle.layer.shadowOpacity = 0.5
self.gameView.addSubview(paddle)
return paddle
}()
Continue reading “cs193p – Project #5 Assignment #5 Step #2 – The Paddle”
