msk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e83ebd96d0dc2a7c3e511e4d75e3ad3f1cad06b8
4
+ data.tar.gz: f6102d4c11f2b8e59ebdaad423429ea78fc222b4
5
+ SHA512:
6
+ metadata.gz: 3a1f7e1533bff4acbd40f1ca143ffb266232a2b1cc93ccf9022647d7e29e24a2054f7b129fe77cdf5a5703cc619d91ad8e12cee03bf101518a0363e0847d033e
7
+ data.tar.gz: 6d5a9e5019044cfd2de31d4d9877498dc792097cf142e74b9cfb6d681bb0cff414c01c1c09ac2ad3a7ac8fe0c08854c54997932ff3d65c4ab2151f8a054b4c98
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jim Nanney
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,170 @@
1
+ # msk - Motion SlicK
2
+
3
+ Motion SlicK is a wrapper of the SpriteKit api that helps make building SpriteKit based games easier.
4
+
5
+ * [Installation](#installation)
6
+ * [Usage](#usage)
7
+ * [Contributing](#contributing)
8
+ * [License](#license)
9
+ * [API Documentation](#api-documentation)
10
+
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'msk'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install msk
25
+
26
+ ## Usage
27
+
28
+ The Motion SlicK gem adds a convenience DSL for SKAction onto the SKNode class. This adds less verbose names for common SKActions, and provides an easy way to build sequences and grouped actions (even nested).
29
+
30
+ For example:
31
+
32
+ ```ruby
33
+ def animate_swap(swap, &block)
34
+ from = swap.tile_b.sprite
35
+ to = swap.tile_a.sprite
36
+ fpos = from.position
37
+ tpos = to.position
38
+ from.zPosition = 90
39
+ to.zPosition = 100
40
+
41
+ to.run_sequence do
42
+ move_to(fpos, 0.3).ease_out
43
+ run_block &block
44
+ end
45
+
46
+ from.run_action move_to(to.position,0.3).ease_out
47
+ run_action @swap_sound
48
+ end
49
+ ```
50
+
51
+ Here we are creating and running a sequence of actions on the ```to``` node.
52
+
53
+ The move_to action takes a position, and optional duration.
54
+
55
+ The DSL adds some more syntactic sugar by adding timing mode additions, such as the ```ease_out`` timing mode above used above.
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create new Pull Request
64
+
65
+ ## License
66
+
67
+ The MIT License (MIT)
68
+
69
+ Copyright (c) 2015 Jim Nanney
70
+
71
+ Permission is hereby granted, free of charge, to any person obtaining a copy
72
+ of this software and associated documentation files (the "Software"), to deal
73
+ in the Software without restriction, including without limitation the rights
74
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
75
+ copies of the Software, and to permit persons to whom the Software is
76
+ furnished to do so, subject to the following conditions:
77
+
78
+ The above copyright notice and this permission notice shall be included in
79
+ all copies or substantial portions of the Software.
80
+
81
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
83
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
84
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
85
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
86
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
87
+ THE SOFTWARE.
88
+
89
+ ## API Documentation
90
+
91
+ ### SKNode Action helper additions
92
+
93
+ #### run_sequence(&block)
94
+
95
+ Creates a Sequence action from the actions contained in the block and then starts the animation.
96
+
97
+ #### run_group(&block)
98
+
99
+ Creates a Group action from the actions contained in the block and then starts the animation.
100
+
101
+ #### group(&block)
102
+
103
+ Creates a Group action from the actions contained in the block and returns it.
104
+
105
+ #### repeat(count, action = nil, &block)
106
+
107
+ Creates a Repeat action for either the action passed in, or a block containing actions to be performed on the node.
108
+
109
+ #### sequence(&block)
110
+
111
+ Creates a Sequence action from the actions contained in the block and returns it.
112
+
113
+ #### move_to(location, duration)
114
+
115
+ Returns a SKAction.moveTo:duration: action
116
+
117
+ #### move_by(delta, duration=0.25)
118
+
119
+ Returns a SKAction.moveBy:duration: action
120
+
121
+ #### fade_in(duration = 0.25)
122
+
123
+ Returns a SKAction.fadeInWithDuration: action
124
+
125
+ #### fade_out(duration = 0.25)
126
+
127
+ Returns a SKAction.fadeOutWithDuration: action
128
+
129
+ #### run_block(&block)
130
+
131
+ Returns a SKAction.runBlock action
132
+
133
+ #### wait(duration = 0.25, with_range = nil)
134
+
135
+ Returns a SKAction.waitForDuration action or SKAction.waitForDuration:withRange action in with_range is specified
136
+
137
+ #### scale_to(scale = 1.0, duration=0.25)
138
+
139
+ Returns a SKAction.scaleTo:duration: action
140
+
141
+ #### remove_from_parent
142
+
143
+ Returns a SKAction.removeFromParent action
144
+
145
+ #### other_action(other)
146
+
147
+ Allows addition of an action that may not have a helper into a sequence
148
+
149
+ ### SKNode position helpers
150
+
151
+ These methods allow easy inspection of the node's position and frame.
152
+
153
+ #### mid_x
154
+ #### mid_y
155
+ #### height
156
+ #### width
157
+ #### top
158
+ #### bottom
159
+ #### left
160
+ #### right
161
+
162
+ ### SKAction helper methods
163
+
164
+ The following methods are added to SKAction to allow setting the timing mode easier. They all return self which allows easy chaining
165
+
166
+ #### ease_in
167
+ #### ease_out
168
+ #### linear
169
+
170
+
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ unless defined?(Motion::Project::Config)
4
+ raise "This file must be required within a RubyMotion project Rakefile."
5
+ end
6
+
7
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
8
+ Motion::Project::App.setup do |app|
9
+ app.files.unshift(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
10
+ end
@@ -0,0 +1,4 @@
1
+ module MSK::Actions
2
+ module Content
3
+ end
4
+ end
@@ -0,0 +1,10 @@
1
+ module MSK::Actions
2
+ module Delay
3
+
4
+ def wait(duration = 0.25, with_range = nil)
5
+ return SKAction.waitForDuration(duration) unless with_range
6
+ SKAction.waitForDuration(duration, with_range)
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module MSK::Actions
2
+ module Kinematics
3
+
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ module MSK::Actions
2
+ module Movement
3
+ def move_to(location, duration)
4
+ SKAction.moveTo(location, duration: duration)
5
+ end
6
+
7
+ def move_by(delta, duration=0.25)
8
+ SKAction.moveBy(delta, duration: duration)
9
+ end
10
+
11
+ def move_by_delta(x, y, duration=0.25)
12
+ SKAction.moveByX(x, y: y, duration: duration)
13
+ end
14
+
15
+ def move_to_x(x, duration=0.25)
16
+ SKAction.moveToX(x, duration: duration)
17
+ end
18
+
19
+ def move_to_y(y, duration=0.25)
20
+ SKAction.moveToY(y, duration: duration)
21
+ end
22
+
23
+ def duration_path(path, duration=0.25, offset=true, orient=true)
24
+ SKAction.followPath(path, asOffset: offset, orientToPath: orient, duration: duration)
25
+ end
26
+
27
+ def speed_path(path, speed=1.0, offset=true, orient=true)
28
+ SKAction.followPath(path, asOffset: offset, orientToPath: orient, speed: speed)
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,5 @@
1
+ module MSK::Actions
2
+ module Properties
3
+
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ module MSK::Actions
2
+ module Rotation
3
+
4
+ def rotate_by(angle, duration=0.25)
5
+ SKAction.rotateBy(angle, duration: duration)
6
+ end
7
+
8
+ def rotate(angle, duration=0.25)
9
+ SKAction.rotateToAngle(angle, duration: duration)
10
+ end
11
+
12
+ def rotate_shortest(angle, duration=0.25, shortest=true)
13
+ SKAction.rotateToAngle(angle, duration: duration, shortestUnitArc: shortest)
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,37 @@
1
+ module MSK::Actions
2
+ module Runners
3
+
4
+ def run_sequence(&block)
5
+ seq = sequence &block
6
+ runAction seq
7
+ end
8
+
9
+ def run_group(&block)
10
+ runAction group(block)
11
+ end
12
+
13
+ def group(&block)
14
+ grp = MSK::DSL::DSL.new(block, self)
15
+ SKAction.group(grp.actions)
16
+ end
17
+
18
+ def repeat(count, action = nil, &block)
19
+ seq = (action) ? action : sequence(&block)
20
+ SKAction.repeatAction(seq, count)
21
+ end
22
+
23
+ def sequence(&block)
24
+ seq = MSK::DSL::DSL.new(block, self)
25
+ SKAction.sequence(seq.actions)
26
+ end
27
+
28
+ def other_action(other)
29
+ other
30
+ end
31
+
32
+ def run_block(&block)
33
+ SKAction.runBlock(block)
34
+ end
35
+ end
36
+ end
37
+
@@ -0,0 +1,29 @@
1
+ module MSK::Actions
2
+ module Scale
3
+
4
+ def scale_by(scale, duration=0.25)
5
+ SKAction.scaleBy(scale, duration: duration)
6
+ end
7
+
8
+ def scale_to(scale = 1.0, duration=0.25)
9
+ SKAction.scaleTo(scale, duration: duration)
10
+ end
11
+
12
+ def scale_xy_by(x, y, duation=0.25)
13
+ SKAction.scaleXBy(x, y: y, duration: duration)
14
+ end
15
+
16
+ def scale_xy_to(x, y, duration=0.25)
17
+ SKAction.scaleXTo(x, y: y, duration: duration)
18
+ end
19
+
20
+ def scale_x(x, duration=0.25)
21
+ SKAction.scaleXTo(x, duration: duration)
22
+ end
23
+
24
+ def scale_y(y, duration=0.25)
25
+ SKAction.scaleYTo(y, duration: duration)
26
+ end
27
+ end
28
+ end
29
+
@@ -0,0 +1,4 @@
1
+ module MSK::Actions
2
+ module Sound
3
+ end
4
+ end
@@ -0,0 +1,13 @@
1
+ module MSK::Actions
2
+ module Speed
3
+ def speed_by(speed, duration=0.25)
4
+ SKAction.speedBy(speed, duration: duration)
5
+ end
6
+
7
+ def speed_to(speed, duration=0.25)
8
+ SKAction.speedTo(speed, duration: duration)
9
+ end
10
+ end
11
+
12
+ end
13
+
@@ -0,0 +1,22 @@
1
+ module MSK::Actions
2
+ module Transparency
3
+
4
+ def fade_in(duration=0.25)
5
+ SKAction.fadeInWithDuration duration
6
+ end
7
+
8
+ def fade_out(duration=0.25)
9
+ SKAction.fadeInWithDuration duration
10
+ end
11
+
12
+ def fadeBy(factor, duration=0.25)
13
+ SKAction.fadeAlphaBy(factor, duration: duration)
14
+ end
15
+
16
+ def fadeTo(alpha, duration=0.25)
17
+ SKAction.fadeAlphaTo(alpha, duration: duration)
18
+ end
19
+
20
+ end
21
+ end
22
+
@@ -0,0 +1,20 @@
1
+ module MSK::Actions
2
+ module Visibility
3
+
4
+ def unhide
5
+ SKAction.unhide
6
+ end
7
+
8
+ def hide
9
+ SKAction.hide
10
+ end
11
+
12
+ def remove_from_parent
13
+ SKAction.removeFromParent
14
+ end
15
+
16
+ alias_method :show, :unhide
17
+
18
+ end
19
+ end
20
+
@@ -0,0 +1,26 @@
1
+ module MSK::DSL
2
+ class DSL
3
+ attr_accessor :actions
4
+
5
+ def initialize(block, parent)
6
+ @actions = []
7
+ @parent = parent
8
+ instance_eval(&block) if block
9
+ end
10
+
11
+ def method_missing(name, *args, &block)
12
+ if @parent.respond_to?(name)
13
+ act = @parent.send(name, *args, &block)
14
+ else
15
+ act = super
16
+ end
17
+ @actions << act if act.kind_of?(SKAction)
18
+ act
19
+ end
20
+
21
+ def respond_to?(name, include_all=false)
22
+ @parent.respond_to?(name) || super
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,38 @@
1
+ module MSK
2
+
3
+ module FrameHelpers
4
+
5
+ def mid_x
6
+ CGRectGetMidX(self.frame)
7
+ end
8
+
9
+ def mid_y
10
+ CGRectGetMidY(self.frame)
11
+ end
12
+
13
+ def height
14
+ CGRectGetHeight(self.frame)
15
+ end
16
+
17
+ def width
18
+ CGRectGetWidth(self.frame)
19
+ end
20
+
21
+ def top
22
+ CGRectGetMaxY(self.frame)
23
+ end
24
+
25
+ def bottom
26
+ CGRectGetMinY(self.frame)
27
+ end
28
+
29
+ def left
30
+ CGRectGetMinX(self.frame)
31
+ end
32
+
33
+ def right
34
+ CGRectGetMaxX(self.frame)
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,24 @@
1
+ module MSK::ActionDSL
2
+ include MSK::Actions::Movement
3
+ include MSK::Actions::Rotation
4
+ include MSK::Actions::Speed
5
+ include MSK::Actions::Scale
6
+ include MSK::Actions::Visibility
7
+ include MSK::Actions::Transparency
8
+ include MSK::Actions::Content
9
+ include MSK::Actions::Sound
10
+ include MSK::Actions::Delay
11
+ include MSK::Actions::Runners
12
+ include MSK::DSL
13
+ end
14
+
15
+ class SKNode
16
+ include MSK::ActionDSL
17
+ include MSK::FrameHelpers
18
+ alias_method :run_action, :runAction
19
+ end
20
+
21
+ class SKAction
22
+ include MSK::ActionTimings
23
+ end
24
+
@@ -0,0 +1,19 @@
1
+ module MSK::ActionTimings
2
+
3
+ def ease_in
4
+ timing_mode = SKActionTimingEaseIn
5
+ self
6
+ end
7
+
8
+ def ease_out
9
+ timing_mode = SKActionTimingEaseOut
10
+ self
11
+ end
12
+
13
+ def linear
14
+ timing_mode = SKActionTimingLinear
15
+ self
16
+ end
17
+
18
+ end
19
+
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: msk
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jim Nanney
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Motion SlicK is a wrapper of the SpriteKit api that helps make building
28
+ SpriteKit based games easier. The Motion SlicK gem adds a convenience DSL for SKAction
29
+ onto the SKNode class. This adds less verbose names for common SKActions, and provides
30
+ an easy way to build sequences and grouped actions (even nested). It also adds a
31
+ few convenience methods for determining SKNode size and boundaries.
32
+ email:
33
+ - jnanney@gmail.com
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - LICENSE
39
+ - README.md
40
+ - lib/msk.rb
41
+ - lib/project/actions/content.rb
42
+ - lib/project/actions/delay.rb
43
+ - lib/project/actions/kinematics.rb
44
+ - lib/project/actions/movement.rb
45
+ - lib/project/actions/properties.rb
46
+ - lib/project/actions/rotation.rb
47
+ - lib/project/actions/runners.rb
48
+ - lib/project/actions/scale.rb
49
+ - lib/project/actions/sound.rb
50
+ - lib/project/actions/speed.rb
51
+ - lib/project/actions/transparency.rb
52
+ - lib/project/actions/visibility.rb
53
+ - lib/project/dsl.rb
54
+ - lib/project/helpers/frame_helpers.rb
55
+ - lib/project/msk.rb
56
+ - lib/project/timings/action_timings.rb
57
+ homepage: https://github.com/jimnanney/motion_slick
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.2.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Motion SlicK is a wrapper of the SpriteKit api that helps make building SpriteKit
81
+ based games easier.
82
+ test_files: []