motion-template-spritekit 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a543383066921b99c6b28561b9fe3163f991043e
4
- data.tar.gz: 471581043b6091865a657834935787d1007b4d24
3
+ metadata.gz: 65dbda814d9f3782ce455143bf87263b9872c5bf
4
+ data.tar.gz: 9b4b46694f2d1293fbfdf5a34ab1e56ff46447a2
5
5
  SHA512:
6
- metadata.gz: b605729a577511119ed57b2d6dd92de66201ed31da7e94f38c1660b3c484044edcd0aa5904ef2d8d0a1d9b947a8fb2009a4dc0dd7e74d456575b5b75c1b0e798
7
- data.tar.gz: 6a470fcf0aac79fe986243ca31bc4584ef42b0036150c120f9533531a71b0def83747842fe93ada269edba100e1742778330f137d5c48e860bc795b7e77539d6
6
+ metadata.gz: 3c088c7d299126779cc00456709e0f087570f509ba7e3f9ed1acaa421714d3e39035b5b5d5fdcb3f69fdb0def0031ab3335fa8471a099ac7bc633327871e3352
7
+ data.tar.gz: 7aa4125c5f512dcfdbd6239ef8a9c92289d41728f29690162f80f2ebe9ca8010176f5114093652ddaf0425341a31e4a91f1b486a823713821230c64ecf329089
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # motion-template-spritekit
1
+ # motion-template-spritekit [![Gem Version](https://badge.fury.io/rb/motion-template-spritekit.png)](http://badge.fury.io/rb/motion-template-spritekit)
2
2
 
3
- Project template for SpriteKit with RubyMotion [![Gem Version](https://badge.fury.io/rb/motion-template-spritekit.png)](http://badge.fury.io/rb/motion-template-spritekit)
3
+ SpriteKit project template for RubyMotion
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,8 +10,22 @@ Install it yourself as:
10
10
 
11
11
  ## Usage
12
12
 
13
+ ### iOS
14
+
13
15
  $ motion create --template=spritekit-ios <app-name>
14
16
 
17
+ ### OSX
18
+
19
+ $ motion create --template=spritekit-osx <app-name>
20
+
21
+ ## In Addition
22
+
23
+ If you need original `Spaceship.png` image, please copy from your own.
24
+ These are the typical locations for the image.
25
+
26
+ /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/Project Templates/Mac/Application/SpriteKit Game.xctemplate/Spaceship.png
27
+ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Application/SpriteKit Game.xctemplate/Spaceship.png
28
+
15
29
  ## Contributing
16
30
 
17
31
  1. Fork it
data/ext/extconf.rb CHANGED
@@ -3,7 +3,7 @@ require 'fileutils'
3
3
 
4
4
  dir = File.expand_path("~/Library/RubyMotion/template/")
5
5
  dir_src_templates = File.expand_path(File.join(File.dirname(__FILE__), "../template"))
6
- templates = %w(spritekit-ios)
6
+ templates = %w(spritekit-ios spritekit-osx)
7
7
  templates.each do |template|
8
8
  src = File.join(dir_src_templates, template)
9
9
  dst = File.join(dir, template)
@@ -1,17 +1,17 @@
1
1
  # coding: utf-8
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "motion-template-spritekit"
6
6
  spec.version = VERSION
7
7
  spec.authors = ["meganemura"]
8
8
  spec.email = ["mura2megane@gmail.com"]
9
- spec.description = %q{Project template for SpriteKit with RubyMotion}
9
+ spec.description = %q{SpriteKit project templates for RubyMotion (iOS/OSX)}
10
10
  spec.summary = %q{Setup SpriteKit template to user's directory}
11
11
  spec.homepage = "https://github.com/meganemura/motion-template-spritekit"
12
12
  spec.license = "MIT"
13
- spec.extensions = ['ext/extconf.rb'] # Command-Line Plugin Installer
13
+ spec.extensions = ['ext/extconf.rb'] # Template Installer
14
14
 
15
- spec.files = `git ls-files`.split($\)
15
+ spec.files = `git ls-files`.split($/)
16
16
  spec.require_paths = ["lib"]
17
17
  end
File without changes
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ # Add your dependencies here:
@@ -0,0 +1 @@
1
+ # <%= name %>
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ $:.unshift("/Library/RubyMotion/lib")
3
+ require 'motion/project/template/osx'
4
+
5
+ begin
6
+ require 'bundler'
7
+ Bundler.require
8
+ rescue LoadError
9
+ end
10
+
11
+ Motion::Project::App.setup do |app|
12
+ # Use `rake config' to see complete project settings.
13
+ app.name = '<%= name %>'
14
+ app.frameworks += ["SpriteKit"]
15
+ end
@@ -0,0 +1,32 @@
1
+ class AppDelegate
2
+ def applicationDidFinishLaunching(notification)
3
+ buildMenu
4
+ buildWindow
5
+ end
6
+
7
+ def buildWindow
8
+ @mainWindow = NSWindow.alloc.initWithContentRect([[240, 180], [480, 360]],
9
+ styleMask: NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask,
10
+ backing: NSBackingStoreBuffered,
11
+ defer: false)
12
+ @mainWindow.title = NSBundle.mainBundle.infoDictionary['CFBundleName']
13
+ @mainWindow.orderFrontRegardless
14
+
15
+ # Pick a size for the scene
16
+ scene = MyScene.sceneWithSize(@mainWindow.frame.size)
17
+ # Set the scale mode to scale to fit the window
18
+ scene.scaleMode = SKSceneScaleModeAspectFit
19
+
20
+ # create a view to sit the scene in
21
+ view = SKView.alloc.initWithFrame(@mainWindow.frame)
22
+ view.presentScene(scene)
23
+ view.showsFPS = true
24
+ view.showsNodeCount = true
25
+
26
+ @mainWindow.setContentView(view)
27
+ end
28
+
29
+ def applicationShouldTerminateAfterLastWindowClosed(sender)
30
+ true
31
+ end
32
+ end
@@ -0,0 +1,110 @@
1
+ class AppDelegate
2
+ def buildMenu
3
+ @mainMenu = NSMenu.new
4
+
5
+ appName = NSBundle.mainBundle.infoDictionary['CFBundleName']
6
+ addMenu(appName) do
7
+ addItemWithTitle("About #{appName}", action: 'orderFrontStandardAboutPanel:', keyEquivalent: '')
8
+ addItem(NSMenuItem.separatorItem)
9
+ addItemWithTitle('Preferences', action: 'openPreferences:', keyEquivalent: ',')
10
+ addItem(NSMenuItem.separatorItem)
11
+ servicesItem = addItemWithTitle('Services', action: nil, keyEquivalent: '')
12
+ NSApp.servicesMenu = servicesItem.submenu = NSMenu.new
13
+ addItem(NSMenuItem.separatorItem)
14
+ addItemWithTitle("Hide #{appName}", action: 'hide:', keyEquivalent: 'h')
15
+ item = addItemWithTitle('Hide Others', action: 'hideOtherApplications:', keyEquivalent: 'H')
16
+ item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
17
+ addItemWithTitle('Show All', action: 'unhideAllApplications:', keyEquivalent: '')
18
+ addItem(NSMenuItem.separatorItem)
19
+ addItemWithTitle("Quit #{appName}", action: 'terminate:', keyEquivalent: 'q')
20
+ end
21
+
22
+ addMenu('File') do
23
+ addItemWithTitle('New', action: 'newDocument:', keyEquivalent: 'n')
24
+ addItemWithTitle('Open…', action: 'openDocument:', keyEquivalent: 'o')
25
+ addItem(NSMenuItem.separatorItem)
26
+ addItemWithTitle('Close', action: 'performClose:', keyEquivalent: 'w')
27
+ addItemWithTitle('Save…', action: 'saveDocument:', keyEquivalent: 's')
28
+ addItemWithTitle('Revert to Saved', action: 'revertDocumentToSaved:', keyEquivalent: '')
29
+ addItem(NSMenuItem.separatorItem)
30
+ addItemWithTitle('Page Setup…', action: 'runPageLayout:', keyEquivalent: 'P')
31
+ addItemWithTitle('Print…', action: 'printDocument:', keyEquivalent: 'p')
32
+ end
33
+
34
+ addMenu('Edit') do
35
+ addItemWithTitle('Undo', action: 'undo:', keyEquivalent: 'z')
36
+ addItemWithTitle('Redo', action: 'redo:', keyEquivalent: 'Z')
37
+ addItem(NSMenuItem.separatorItem)
38
+ addItemWithTitle('Cut', action: 'cut:', keyEquivalent: 'x')
39
+ addItemWithTitle('Copy', action: 'copy:', keyEquivalent: 'c')
40
+ addItemWithTitle('Paste', action: 'paste:', keyEquivalent: 'v')
41
+ item = addItemWithTitle('Paste and Match Style', action: 'pasteAsPlainText:', keyEquivalent: 'V')
42
+ item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
43
+ addItemWithTitle('Delete', action: 'delete:', keyEquivalent: '')
44
+ addItemWithTitle('Select All', action: 'selectAll:', keyEquivalent: 'a')
45
+ end
46
+
47
+ fontMenu = createMenu('Font') do
48
+ addItemWithTitle('Show Fonts', action: 'orderFrontFontPanel:', keyEquivalent: 't')
49
+ addItemWithTitle('Bold', action: 'addFontTrait:', keyEquivalent: 'b')
50
+ addItemWithTitle('Italic', action: 'addFontTrait:', keyEquivalent: 'i')
51
+ addItemWithTitle('Underline', action: 'underline:', keyEquivalent: 'u')
52
+ addItem(NSMenuItem.separatorItem)
53
+ addItemWithTitle('Bigger', action: 'modifyFont:', keyEquivalent: '+')
54
+ addItemWithTitle('Smaller', action: 'modifyFont:', keyEquivalent: '-')
55
+ end
56
+
57
+ textMenu = createMenu('Text') do
58
+ addItemWithTitle('Align Left', action: 'alignLeft:', keyEquivalent: '{')
59
+ addItemWithTitle('Center', action: 'alignCenter:', keyEquivalent: '|')
60
+ addItemWithTitle('Justify', action: 'alignJustified:', keyEquivalent: '')
61
+ addItemWithTitle('Align Right', action: 'alignRight:', keyEquivalent: '}')
62
+ addItem(NSMenuItem.separatorItem)
63
+ addItemWithTitle('Show Ruler', action: 'toggleRuler:', keyEquivalent: '')
64
+ item = addItemWithTitle('Copy Ruler', action: 'copyRuler:', keyEquivalent: 'c')
65
+ item.keyEquivalentModifierMask = NSCommandKeyMask|NSControlKeyMask
66
+ item = addItemWithTitle('Paste Ruler', action: 'pasteRuler:', keyEquivalent: 'v')
67
+ item.keyEquivalentModifierMask = NSCommandKeyMask|NSControlKeyMask
68
+ end
69
+
70
+ addMenu('Format') do
71
+ addItem fontMenu
72
+ addItem textMenu
73
+ end
74
+
75
+ addMenu('View') do
76
+ item = addItemWithTitle('Show Toolbar', action: 'toggleToolbarShown:', keyEquivalent: 't')
77
+ item.keyEquivalentModifierMask = NSCommandKeyMask|NSAlternateKeyMask
78
+ addItemWithTitle('Customize Toolbar…', action: 'runToolbarCustomizationPalette:', keyEquivalent: '')
79
+ end
80
+
81
+ NSApp.windowsMenu = addMenu('Window') do
82
+ addItemWithTitle('Minimize', action: 'performMiniaturize:', keyEquivalent: 'm')
83
+ addItemWithTitle('Zoom', action: 'performZoom:', keyEquivalent: '')
84
+ addItem(NSMenuItem.separatorItem)
85
+ addItemWithTitle('Bring All To Front', action: 'arrangeInFront:', keyEquivalent: '')
86
+ end.menu
87
+
88
+ NSApp.helpMenu = addMenu('Help') do
89
+ addItemWithTitle("#{appName} Help", action: 'showHelp:', keyEquivalent: '?')
90
+ end.menu
91
+
92
+ NSApp.mainMenu = @mainMenu
93
+ end
94
+
95
+ private
96
+
97
+ def addMenu(title, &b)
98
+ item = createMenu(title, &b)
99
+ @mainMenu.addItem item
100
+ item
101
+ end
102
+
103
+ def createMenu(title, &b)
104
+ menu = NSMenu.alloc.initWithTitle(title)
105
+ menu.instance_eval(&b) if b
106
+ item = NSMenuItem.alloc.initWithTitle(title, action: nil, keyEquivalent: '')
107
+ item.submenu = menu
108
+ item
109
+ end
110
+ end
@@ -0,0 +1,37 @@
1
+ class MyScene < SKScene
2
+ def initWithSize(size)
3
+ super
4
+
5
+ self.backgroundColor = SKColor.grayColor
6
+ my_label = SKLabelNode.labelNodeWithFontNamed("Chalkduster")
7
+ my_label.text = "Hello, World!"
8
+ my_label.fontSize = 30
9
+ my_label.position = CGPointMake(CGRectGetMidX(self.frame),
10
+ CGRectGetMidY(self.frame))
11
+ self.addChild(my_label)
12
+ self
13
+ end
14
+
15
+ def mouseDown(theEvent)
16
+ # Called when a mouse click occurs
17
+ location = theEvent.locationInNode(self)
18
+
19
+ # build a sprite for the scene
20
+ sprite = SKSpriteNode.spriteNodeWithImageNamed("Spaceship")
21
+ sprite.position = location
22
+ sprite.scale = 0.3
23
+
24
+ # rotate the sprite a small amount
25
+ action = SKAction.rotateByAngle(Math::PI, duration:0.5)
26
+
27
+ # repeat this action forever
28
+ sprite.runAction(SKAction.repeatActionForever(action))
29
+
30
+ # add the sprite to the scene
31
+ self.addChild(sprite)
32
+ end
33
+
34
+ def update(current_time)
35
+ # Called before each frame is rendered
36
+ end
37
+ end
@@ -0,0 +1 @@
1
+ SKColor = NSColor
@@ -0,0 +1,29 @@
1
+ {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
2
+ {\colortbl;\red255\green255\blue255;}
3
+ \paperw9840\paperh8400
4
+ \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
5
+
6
+ \f0\b\fs24 \cf0 Engineering:
7
+ \b0 \
8
+ Some people\
9
+ \
10
+
11
+ \b Human Interface Design:
12
+ \b0 \
13
+ Some other people\
14
+ \
15
+
16
+ \b Testing:
17
+ \b0 \
18
+ Hopefully not nobody\
19
+ \
20
+
21
+ \b Documentation:
22
+ \b0 \
23
+ Whoever\
24
+ \
25
+
26
+ \b With special thanks to:
27
+ \b0 \
28
+ Mom\
29
+ }
@@ -0,0 +1,9 @@
1
+ describe "Application '<%= name %>'" do
2
+ before do
3
+ @app = NSApplication.sharedApplication
4
+ end
5
+
6
+ it "has one window" do
7
+ @app.windows.size.should == 1
8
+ end
9
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-template-spritekit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - meganemura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-17 00:00:00.000000000 Z
11
+ date: 2014-07-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Project template for SpriteKit with RubyMotion
13
+ description: SpriteKit project templates for RubyMotion (iOS/OSX)
14
14
  email:
15
15
  - mura2megane@gmail.com
16
16
  executables: []
@@ -33,8 +33,20 @@ files:
33
33
  - template/spritekit-ios/files/app/sprite_kit_base.rb
34
34
  - template/spritekit-ios/files/app/view_controller.rb
35
35
  - template/spritekit-ios/files/resources/Default-568h@2x.png
36
+ - template/spritekit-ios/files/resources/Spaceship.png
36
37
  - template/spritekit-ios/files/spec/main_spec.rb.erb
37
38
  - template/spritekit-osx/.gitkeep
39
+ - template/spritekit-osx/files/.gitkeep
40
+ - template/spritekit-osx/files/Gemfile
41
+ - template/spritekit-osx/files/README.md.erb
42
+ - template/spritekit-osx/files/Rakefile.erb
43
+ - template/spritekit-osx/files/app/app_delegate.rb
44
+ - template/spritekit-osx/files/app/menu.rb
45
+ - template/spritekit-osx/files/app/my_scene.rb
46
+ - template/spritekit-osx/files/app/sprite_kit_base.rb
47
+ - template/spritekit-osx/files/resources/Credits.rtf
48
+ - template/spritekit-osx/files/resources/Spaceship.png
49
+ - template/spritekit-osx/files/spec/main_spec.rb.erb
38
50
  homepage: https://github.com/meganemura/motion-template-spritekit
39
51
  licenses:
40
52
  - MIT