Skip to content

Commit

Permalink
coordinate fixes, add dynamic features
Browse files Browse the repository at this point in the history
- add dynamics properties to layers and objects
- `SKTilemap.baseLayer` is ignored when querying layers
- add Data extension to check for compressed data
- fix coordinate error with negative tile coordinates
  • Loading branch information
mfessenden committed Nov 8, 2016
1 parent 5ea1064 commit 5c838fe
Show file tree
Hide file tree
Showing 25 changed files with 348 additions and 205 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Change Log
==========================
1.0.5
--------------------------

#### Changes
- add dynamics properties to layers and objects
- `SKTilemap.baseLayer` is ignored when querying layers
- add Data extension to check for compressed data
- fix coordinate error with negative tile coordinates

1.0.4
--------------------------
Expand Down
1 change: 1 addition & 0 deletions Resources/DemoFiles.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>maze-pacman</string>
<string>ortho4-16x16</string>
<string>isometric-130x66</string>
<string>staggered-64x33</string>
Expand Down
2 changes: 1 addition & 1 deletion Resources/ortho4-16x16.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
<objectgroup name="Locations" visible="0">
<objectgroup name="Locations">
<properties>
<property name="lineWidth" type="float" value="1.5"/>
</properties>
Expand Down
19 changes: 14 additions & 5 deletions Resources/staggered-64x33.tmx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="staggered" renderorder="right-down" width="15" height="35" tilewidth="64" tileheight="33" staggeraxis="y" staggerindex="odd" backgroundcolor="#000000" nextobjectid="4">
<map version="1.0" orientation="staggered" renderorder="right-down" width="15" height="35" tilewidth="64" tileheight="33" staggeraxis="y" staggerindex="odd" backgroundcolor="#000000" nextobjectid="12">
<properties>
<property name="autoResize" type="bool" value="true"/>
<property name="frameColor" type="color" value="#ff4f5051"/>
Expand Down Expand Up @@ -180,11 +180,20 @@
</data>
</layer>
<objectgroup name="Locations">
<object id="2" name="carpet" x="64" y="448">
<properties>
<property name="color" type="color" value="#ff55d633"/>
</properties>
<object id="2" name="carpet1" x="64" y="448">
<polygon points="32,16 288,-112 416,-48 160,80"/>
</object>
<object id="7" name="window1" x="612" y="45">
<polygon points="0,0 0,84 53.3333,112 53.3333,28"/>
</object>
<object id="8" name="window2" x="708" y="93">
<polygon points="0,0 0,84 53.3333,112 53.3333,28"/>
</object>
<object id="9" name="window3" x="802" y="139">
<polygon points="0,0 0,84 53.3333,112 53.3333,28"/>
</object>
<object id="10" name="window4" x="900" y="188">
<polygon points="0,0 0,84 53.3333,112 53.3333,28"/>
</object>
</objectgroup>
</map>
22 changes: 22 additions & 0 deletions SKTiled.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
4C440BB51DAE913A00DEC9A4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4C440BAF1DAE913A00DEC9A4 /* Main.storyboard */; };
4C440BB61DAE913A00DEC9A4 /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C440BB11DAE913A00DEC9A4 /* GameViewController.swift */; };
4C5479FE1DC15AF6008B3473 /* GameWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C5479FD1DC15AF6008B3473 /* GameWindowController.swift */; };
4C7D8EEB1DD26C78007A943A /* maze-pacman.tmx in Resources */ = {isa = PBXBuildFile; fileRef = 4C7D8EE81DD26C78007A943A /* maze-pacman.tmx */; };
4C7D8EEC1DD26C78007A943A /* maze-pacman.tmx in Resources */ = {isa = PBXBuildFile; fileRef = 4C7D8EE81DD26C78007A943A /* maze-pacman.tmx */; };
4C7D8EED1DD26C78007A943A /* spritesheet-8x8.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C7D8EE91DD26C78007A943A /* spritesheet-8x8.png */; };
4C7D8EEE1DD26C78007A943A /* spritesheet-8x8.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C7D8EE91DD26C78007A943A /* spritesheet-8x8.png */; };
4C7D8EEF1DD26C78007A943A /* spritesheet-8x8.tsx in Resources */ = {isa = PBXBuildFile; fileRef = 4C7D8EEA1DD26C78007A943A /* spritesheet-8x8.tsx */; };
4C7D8EF01DD26C78007A943A /* spritesheet-8x8.tsx in Resources */ = {isa = PBXBuildFile; fileRef = 4C7D8EEA1DD26C78007A943A /* spritesheet-8x8.tsx */; };
4C88E18C1D8A1BC400FCCFA3 /* roguelike-16x16.tmx in Resources */ = {isa = PBXBuildFile; fileRef = 4C88E18B1D8A1BC400FCCFA3 /* roguelike-16x16.tmx */; };
4C88E1AB1D8A241F00FCCFA3 /* ortho4-16x16.tmx in Resources */ = {isa = PBXBuildFile; fileRef = 4C88E1AA1D8A241F00FCCFA3 /* ortho4-16x16.tmx */; };
4C88E1AD1D8A242F00FCCFA3 /* ortho4-16x16.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C88E1AC1D8A242F00FCCFA3 /* ortho4-16x16.png */; };
Expand Down Expand Up @@ -91,6 +97,9 @@
4C440BB11DAE913A00DEC9A4 /* GameViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = "<group>"; };
4C440BB21DAE913A00DEC9A4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4C5479FD1DC15AF6008B3473 /* GameWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameWindowController.swift; sourceTree = "<group>"; };
4C7D8EE81DD26C78007A943A /* maze-pacman.tmx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = "maze-pacman.tmx"; path = "dev/tiled/pacman-error/maze-pacman.tmx"; sourceTree = SOURCE_ROOT; };
4C7D8EE91DD26C78007A943A /* spritesheet-8x8.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "spritesheet-8x8.png"; path = "dev/tiled/pacman-error/spritesheet-8x8.png"; sourceTree = SOURCE_ROOT; };
4C7D8EEA1DD26C78007A943A /* spritesheet-8x8.tsx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = "spritesheet-8x8.tsx"; path = "dev/tiled/pacman-error/spritesheet-8x8.tsx"; sourceTree = SOURCE_ROOT; };
4C88E18B1D8A1BC400FCCFA3 /* roguelike-16x16.tmx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "roguelike-16x16.tmx"; sourceTree = "<group>"; };
4C88E1AA1D8A241F00FCCFA3 /* ortho4-16x16.tmx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "ortho4-16x16.tmx"; sourceTree = "<group>"; };
4C88E1AC1D8A242F00FCCFA3 /* ortho4-16x16.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ortho4-16x16.png"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -194,6 +203,9 @@
4C7A77AA1DA6A21A0018A55D /* External */ = {
isa = PBXGroup;
children = (
4C7D8EE81DD26C78007A943A /* maze-pacman.tmx */,
4C7D8EE91DD26C78007A943A /* spritesheet-8x8.png */,
4C7D8EEA1DD26C78007A943A /* spritesheet-8x8.tsx */,
);
name = External;
sourceTree = "<group>";
Expand Down Expand Up @@ -371,10 +383,12 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4C7D8EEC1DD26C78007A943A /* maze-pacman.tmx in Resources */,
4C8E42E11DC26FD1002C76DA /* zlib in Resources */,
4C1774AC1D90999C000C0AFD /* roguelike-16x16-anim.png in Resources */,
4C1774A21D90999C000C0AFD /* hex1-65x65.tmx in Resources */,
4C1774A71D90999C000C0AFD /* staggered-64x33.tmx in Resources */,
4C7D8EF01DD26C78007A943A /* spritesheet-8x8.tsx in Resources */,
4C1774A81D90999C000C0AFD /* hex-65x65-65x230.png in Resources */,
4C440B9C1DAE911000DEC9A4 /* Assets.xcassets in Resources */,
4C1774A61D90999C000C0AFD /* roguelike-16x16.tmx in Resources */,
Expand All @@ -385,6 +399,7 @@
4C1774A11D90999C000C0AFD /* DemoFiles.plist in Resources */,
4C1774AB1D90999C000C0AFD /* ortho4-16x16.png in Resources */,
4C1774AE1D90999C000C0AFD /* roguelike-16x16.tsx in Resources */,
4C7D8EEE1DD26C78007A943A /* spritesheet-8x8.png in Resources */,
4C1774A41D90999C000C0AFD /* isometric-130x66.tmx in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -393,6 +408,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4C7D8EEB1DD26C78007A943A /* maze-pacman.tmx in Resources */,
4CFEA35D1D8D04320055C150 /* hex1-65x65.tmx in Resources */,
4CBA61831D8A0A4600B31FC1 /* roguelike-16x16-anim.png in Resources */,
4C88E1AB1D8A241F00FCCFA3 /* ortho4-16x16.tmx in Resources */,
Expand All @@ -403,11 +419,13 @@
4C440BB51DAE913A00DEC9A4 /* Main.storyboard in Resources */,
4CFEA3591D8D02D20055C150 /* staggered-64x192.png in Resources */,
4CA3DA0E1D8AF07C001E165A /* DemoFiles.plist in Resources */,
4C7D8EED1DD26C78007A943A /* spritesheet-8x8.png in Resources */,
4CD6D2DE1D8B9EA10083DA7B /* isometric-130x230.png in Resources */,
4CFEA35C1D8D04320055C150 /* hex-65x65-65x230.png in Resources */,
4CFEA3581D8D02D20055C150 /* staggered-64x33.tmx in Resources */,
4C440BB41DAE913A00DEC9A4 /* LaunchScreen.storyboard in Resources */,
4CD6D2D51D8B9DE20083DA7B /* roguelike-16x16.tsx in Resources */,
4C7D8EEF1DD26C78007A943A /* spritesheet-8x8.tsx in Resources */,
4CD6D2DD1D8B9EA10083DA7B /* isometric-130x66.tmx in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -518,7 +536,9 @@
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = 747QKN4G7U;
DSTROOT = /;
INFOPLIST_FILE = "$(SRCROOT)/macOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
Expand All @@ -539,7 +559,9 @@
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
DEPLOYMENT_LOCATION = YES;
DEVELOPMENT_TEAM = 747QKN4G7U;
DSTROOT = /;
INFOPLIST_FILE = "$(SRCROOT)/macOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
Expand Down
28 changes: 26 additions & 2 deletions Shared/ButtonNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ open class ButtonNode: SKSpriteNode {

// textures
open var selectedTexture: SKTexture!
open var hoveredTexture: SKTexture!
open var defaultTexture: SKTexture! {
didSet {
defaultTexture.filteringMode = .linear
Expand All @@ -40,8 +41,9 @@ open class ButtonNode: SKSpriteNode {
}
}

// action to show highlight scaling
// actions to show highlight scaling & hover (OSX)
fileprivate let scaleAction: SKAction = SKAction.scale(by: 0.95, duration: 0.025)
fileprivate let hoverAction: SKAction = SKAction.colorize(with: SKColor.white, colorBlendFactor: 0.5, duration: 0.025)

public init(defaultImage: String, highlightImage: String, action: @escaping () -> ()) {
buttonAction = action
Expand Down Expand Up @@ -95,11 +97,21 @@ open class ButtonNode: SKSpriteNode {
didSet {
// Guard against repeating the same action.
guard oldValue != wasPressed else { return }
texture = wasPressed ? selectedTexture : defaultTexture
let action = wasPressed ? scaleAction : scaleAction.reversed()
run(action)
}
}

// swap textures when mouse hovers
open var mouseHover = false {
didSet {
// Guard against repeating the same action.
guard oldValue != mouseHover else { return }
texture = mouseHover ? selectedTexture : defaultTexture
let action = mouseHover ? hoverAction : hoverAction.reversed()
run(action)
}
}
}

#if os(iOS)
Expand Down Expand Up @@ -147,6 +159,18 @@ public extension ButtonNode {
#if os(OSX)
extension ButtonNode {

override open func mouseEntered(with event: NSEvent) {
if isUserInteractionEnabled {
if containsEvent(event){
mouseHover = true
}
}
}

override open func mouseExited(with event: NSEvent) {
mouseHover = false
}

override open func mouseDown(with event: NSEvent) {
if isUserInteractionEnabled {
wasPressed = true
Expand Down
Loading

0 comments on commit 5c838fe

Please sign in to comment.