adjusted game visuals and hit-tested the tap gesture against the bucket area
This commit is contained in:
parent
934387dfff
commit
e69d8eda4f
22
Privyet/Assets.xcassets/panelback.imageset/Contents.json
vendored
Normal file
22
Privyet/Assets.xcassets/panelback.imageset/Contents.json
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "panelback.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "panelback@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
Privyet/Assets.xcassets/panelback.imageset/panelback.png
vendored
Normal file
BIN
Privyet/Assets.xcassets/panelback.imageset/panelback.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
Privyet/Assets.xcassets/panelback.imageset/panelback@2x.png
vendored
Normal file
BIN
Privyet/Assets.xcassets/panelback.imageset/panelback@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
|
@ -15,50 +15,47 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rZI-CB-OQn">
|
||||
<rect key="frame" x="310" y="315" width="84" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="whitebg" translatesAutoresizingMaskIntoConstraints="NO" id="2kD-q4-jVs">
|
||||
<rect key="frame" x="0.0" y="0.0" width="84" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SCORE" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="InR-1s-zXh">
|
||||
<rect key="frame" x="7" y="20" width="70" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="Avenir-Black" family="Avenir" pointSize="15"/>
|
||||
<color key="textColor" red="0.13333333333333333" green="0.6470588235294118" blue="0.82745098039215681" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="999" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Zja-c9-zBQ">
|
||||
<rect key="frame" x="0.0" y="45" width="84" height="39"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="Avenir-Light" family="Avenir" pointSize="35"/>
|
||||
<color key="textColor" red="0.1333333333" green="0.64705882349999999" blue="0.82745098039999998" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="NEXT" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kjl-Kl-IpX">
|
||||
<rect key="frame" x="257" y="44" width="40" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="Avenir-Heavy" family="Avenir" pointSize="15"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5g3-e3-yLO">
|
||||
<rect key="frame" x="310" y="482" width="84" height="100"/>
|
||||
<rect key="frame" x="310" y="538" width="84" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="whitebg" translatesAutoresizingMaskIntoConstraints="NO" id="nRI-Ry-bjG">
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="panelback" translatesAutoresizingMaskIntoConstraints="NO" id="nRI-Ry-bjG">
|
||||
<rect key="frame" x="0.0" y="0.0" width="84" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="LEVEL" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Boc-bL-hFe">
|
||||
<rect key="frame" x="7" y="20" width="70" height="21"/>
|
||||
<rect key="frame" x="7" y="51" width="70" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="Avenir-Black" family="Avenir" pointSize="15"/>
|
||||
<color key="textColor" red="0.54509803921568623" green="0.45490196078431372" blue="0.76078431372549016" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="textColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="999" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="G8x-d8-J4Q">
|
||||
<rect key="frame" x="0.0" y="45" width="84" height="39"/>
|
||||
<rect key="frame" x="0.0" y="70" width="84" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="Avenir-Light" family="Avenir" pointSize="35"/>
|
||||
<color key="textColor" red="0.54509803921568623" green="0.45490196078431372" blue="0.76078431372549016" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<fontDescription key="fontDescription" name="Avenir-Black" family="Avenir" pointSize="20"/>
|
||||
<color key="textColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SCORE" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="InR-1s-zXh">
|
||||
<rect key="frame" x="7" y="4" width="70" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="Avenir-Black" family="Avenir" pointSize="15"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="999" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Zja-c9-zBQ">
|
||||
<rect key="frame" x="0.0" y="14" width="84" height="39"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" name="Avenir-Black" family="Avenir" pointSize="20"/>
|
||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
|
@ -99,10 +96,10 @@
|
|||
</connections>
|
||||
</swipeGestureRecognizer>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-64" y="86"/>
|
||||
<point key="canvasLocation" x="-65.217391304347828" y="85.714285714285708"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="whitebg" width="84" height="100"/>
|
||||
<image name="panelback" width="84" height="100"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
|
|
@ -22,6 +22,8 @@ class GameScene: SKScene {
|
|||
var tickLengthMillis = TickLengthLevelOne
|
||||
var lastTick: NSDate?
|
||||
|
||||
var scaleFactor: CGFloat!
|
||||
|
||||
var textureCache = Dictionary<String, SKTexture>()
|
||||
var textureAtlas: SKTextureAtlas?
|
||||
|
||||
|
@ -41,7 +43,7 @@ class GameScene: SKScene {
|
|||
//print("Background is sized \(background.size)")
|
||||
|
||||
// Scale computations
|
||||
let scaleFactor = min(size.width / background.size.width, size.height / background.size.height)
|
||||
scaleFactor = CGFloat(min(size.width / background.size.width, size.height / background.size.height))
|
||||
|
||||
background.position = CGPoint(x: 0, y: 0)
|
||||
background.anchorPoint = CGPoint(x: 0, y: 1.0)
|
||||
|
@ -98,6 +100,12 @@ class GameScene: SKScene {
|
|||
return CGPoint(x: x, y: y)
|
||||
}
|
||||
|
||||
func rectForBucket() -> CGRect {
|
||||
let width = CGFloat(NumColumns) * BlockSize
|
||||
let height = CGFloat(NumRows) * BlockSize
|
||||
return CGRect(x: (LayerPosition.x + (BlockSize / 2)) * scaleFactor, y: (LayerPosition.y + (BlockSize / 2)) * scaleFactor, width: width * scaleFactor, height: height * scaleFactor)
|
||||
}
|
||||
|
||||
// Add the "preview" shape to the current scene. This also "rezzes in" a shape's block sprites.
|
||||
func addPreviewShapeToScene(shape: Shape, completion: @escaping () -> ()) {
|
||||
for block in shape.blocks {
|
||||
|
|
|
@ -13,6 +13,7 @@ import GameplayKit
|
|||
class GameViewController: UIViewController, PrivyetDelegate, UIGestureRecognizerDelegate {
|
||||
var scene: GameScene!
|
||||
var privyet: Privyet!
|
||||
var bucketRect: CGRect!
|
||||
var panPointReference: CGPoint?
|
||||
|
||||
@IBOutlet weak var scoreLabel: UILabel!
|
||||
|
@ -29,6 +30,9 @@ class GameViewController: UIViewController, PrivyetDelegate, UIGestureRecognizer
|
|||
scene = GameScene(size: skView.bounds.size)
|
||||
scene.scaleMode = .aspectFill
|
||||
|
||||
bucketRect = scene.rectForBucket()
|
||||
print("Computed bucket rectangle = \(bucketRect!)")
|
||||
|
||||
scene.tick = didTick
|
||||
|
||||
privyet = Privyet()
|
||||
|
@ -45,7 +49,10 @@ class GameViewController: UIViewController, PrivyetDelegate, UIGestureRecognizer
|
|||
|
||||
// Called when the user taps the screen
|
||||
@IBAction func didTap(_ sender: UITapGestureRecognizer) {
|
||||
privyet.rotateShape()
|
||||
let tapLoc = sender.location(in: view)
|
||||
if bucketRect.contains(tapLoc) {
|
||||
privyet.rotateShape()
|
||||
}
|
||||
}
|
||||
|
||||
// Called when the user slides their finger across the screen
|
||||
|
|
|
@ -15,7 +15,7 @@ let StartingColumn = 4
|
|||
let StartingRow = 0
|
||||
|
||||
let PreviewColumn = 12
|
||||
let PreviewRow = 1
|
||||
let PreviewRow = 3
|
||||
|
||||
let PointsPerLine = 10
|
||||
let LevelThreshold = 500
|
||||
|
|
Loading…
Reference in New Issue
Block a user