Last active
August 29, 2015 14:01
Revisions
-
willrax revised this gist
May 10, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def add_ground 2.times do |i| ground = SKSpriteNode.spriteNodeWithTexture ground_texture ground.position = CGPointMake(x + (i * x * 2), 56) ground.runAction scroll_action(x, 0.02) addChild ground end -
willrax revised this gist
May 10, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,6 @@ def scroll_action(x, duration) end def add_ground x = CGRectGetMidX(self.frame) + 7 2.times do |i| -
willrax revised this gist
May 10, 2014 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,11 +10,11 @@ def scroll_action(x, duration) end def add_ground texture = x = CGRectGetMidX(self.frame) + 7 2.times do |i| ground = SKSpriteNode.spriteNodeWithTexture ground_texture ground.position = CGPointMake(x + (i * x * 2), 56) ground.runAction scroll_action(x, :ground) @@ -34,6 +34,10 @@ def sky_texture SKTexture.textureWithImageNamed "skyline.png" end def ground_texture SKTexture.textureWithImageNamed "ground.png" end def add_skyline 2.times do |i| x_position = mid_x + (i * mid_x * 2) -
willrax revised this gist
May 10, 2014 . 1 changed file with 15 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,27 @@ # Video of it in action: http://cl.ly/VSIF class MyScene < SKScene def scroll_action(x, duration) width = (x * 2) move = SKAction.moveByX(-width, y: 0, duration: duration * width) reset = SKAction.moveByX(width, y: 0, duration: 0) SKAction.repeatActionForever(SKAction.sequence([move, reset])) end def add_ground texture = SKTexture.textureWithImageNamed "ground.png" x = CGRectGetMidX(self.frame) + 7 2.times do |i| ground = SKSpriteNode.spriteNodeWithTexture texture ground.position = CGPointMake(x + (i * x * 2), 56) ground.runAction scroll_action(x, :ground) addChild ground end end def mid_x CGRectGetMidX(self.frame) end @@ -24,29 +37,14 @@ def sky_texture def add_skyline 2.times do |i| x_position = mid_x + (i * mid_x * 2) skyline = SKSpriteNode.spriteNodeWithTexture sky_texture skyline.position = CGPointMake(x_position, mid_y) skyline.zPosition = -20 skyline.scale = 1.12 skyline.runAction scroll_action(mid_x, 0.1) addChild skyline end end end -
willrax revised this gist
May 10, 2014 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,11 +38,12 @@ def add_skyline def add_ground texture = SKTexture.textureWithImageNamed "ground.png" x_position = mid_x + 7 x_position = 2.times do |i| ground = SKSpriteNode.spriteNodeWithTexture texture ground.position = CGPointMake(half_width + (i * half_width* 2),56) ground.runAction scroll_action(x_position, 0.02) addChild ground -
willrax revised this gist
May 10, 2014 . 1 changed file with 29 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,41 +1,51 @@ # Video of it in action: http://cl.ly/VSIF class MyScene < SKScene def scroll_action(x, duration) width = (x * 2) move = SKAction.moveByX(-width, y: 0, duration: duration * width) reset = SKAction.moveByX(width, y: 0, duration: 0) SKAction.repeatActionForever(SKAction.sequence([move, reset])) end def mid_x CGRectGetMidX(self.frame) end def mid_y CGRectGetMidY(self.frame) end def sky_texture SKTexture.textureWithImageNamed "skyline.png" end def add_skyline 2.times do |i| x_position = mid_x + (i * mid_x * 2) skyline = SKSpriteNode.spriteNodeWithTexture sky_texture skyline.position = CGPointMake(x_position, mid_y) skyline.zPosition = -20 skyline.scale = 1.12 skyline.runAction scroll_action(mid_x, 0.1) addChild skyline end end def add_ground texture = SKTexture.textureWithImageNamed "ground.png" x_position = mid_x + 7 + (i * half_width* 2), 2.times do |i| ground = SKSpriteNode.spriteNodeWithTexture texture ground.position = CGPointMake(x_position 56) ground.runAction scroll_action(x_position, 0.02) addChild ground end end end -
willrax revised this gist
May 10, 2014 . 1 changed file with 21 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,40 +1,41 @@ # Video of it in action: http://cl.ly/VSIF class MyScene < SKScene def scroll_action(x, type) duration = type == :ground ? 0.02 : 0.1 width = (x * 2) move = SKAction.moveByX(-width, y: 0, duration: duration * width) reset = SKAction.moveByX(width, y: 0, duration: 0) SKAction.repeatActionForever(SKAction.sequence([move, reset])) end def add_ground texture = SKTexture.textureWithImageNamed "ground.png" x = CGRectGetMidX(self.frame) + 7 2.times do |i| ground = SKSpriteNode.spriteNodeWithTexture texture ground.position = CGPointMake(x + (i * x * 2), 56) ground.runAction scroll_action(x, :ground) addChild ground end end def add_skyline texture = SKTexture.textureWithImageNamed "skyline.png" x = CGRectGetMidX(self.frame) 2.times do |i| skyline = SKSpriteNode.spriteNodeWithTexture texture skyline.scale = 1.12 skyline.position = CGPointMake(x + (i * x * 2), CGRectGetMidY(self.frame)) skyline.zPosition = -20 skyline.runAction scroll_action(x, :skyline) addChild skyline end end end -
willrax revised this gist
May 10, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Video of it in action: http://cl.ly/VSIF class MyScene < SKScene def add_skyline -
willrax revised this gist
May 10, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Video: http://cl.ly/VSIF class MyScene < SKScene def add_skyline -
willrax revised this gist
May 10, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # Video: https://www.dropbox.com/s/e0pw03fu1lz65q4/parallax.mov class MyScene < SKScene def add_skyline texture = SKTexture.textureWithImageNamed "skyline.png" -
willrax revised this gist
May 10, 2014 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,20 @@ def add_skyline end end def add_ground texture = SKTexture.textureWithImageNamed "ground.png" x = CGRectGetMidX(self.frame) + 7 2.times do |i| ground = SKSpriteNode.spriteNodeWithTexture texture ground.position = CGPointMake(x + (i * x * 2), 56) ground.runAction scroll_action(x) addChild ground end end def scroll_action(x) width = (x * 2) move = SKAction.moveByX(-width, y: 0, duration: 0.02 * width) reset = SKAction.moveByX(width, y: 0, duration: 0) -
willrax created this gist
May 10, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ class MyScene < SKScene def add_skyline texture = SKTexture.textureWithImageNamed "skyline.png" x = CGRectGetMidX(self.frame) 2.times do |i| skyline = SKSpriteNode.spriteNodeWithTexture texture skyline.scale = 1.12 skyline.position = CGPointMake(x + (i * x * 2), CGRectGetMidY(self.frame)) skyline.zPosition = -20 skyline.runAction scroll_action(x) addChild skyline end end def scroll_action(x) width = (x * 2) move = SKAction.moveByX(-width, y: 0, duration: 0.02 * width) reset = SKAction.moveByX(width, y: 0, duration: 0) SKAction.repeatActionForever(SKAction.sequence([move, reset])) end end