opal-phaser 0.3.0 → 0.4.5
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 +4 -4
- data/README.md +10 -2
- data/demo/app/main.rb +4 -4
- data/demo/index.html +2 -1
- data/lib/opal/phaser.rb +1 -0
- data/lib/opal/phaser/animation/animation.rb +8 -6
- data/lib/opal/phaser/core/game.rb +17 -1
- data/lib/opal/phaser/core/loader.rb +3 -1
- data/lib/opal/phaser/game_objects/game_object_factory.rb +2 -0
- data/lib/opal/phaser/game_objects/image.rb +11 -14
- data/lib/opal/phaser/game_objects/sprite.rb +8 -18
- data/lib/opal/phaser/game_objects/tile_sprite.rb +1 -1
- data/lib/opal/phaser/geometry/point.rb +2 -0
- data/lib/opal/phaser/geometry/rectangle.rb +8 -3
- data/lib/opal/phaser/pixi/canvas_renderer.rb +2 -0
- data/lib/opal/phaser/pixi/web_gl_renderer.rb +3 -0
- data/lib/opal/phaser/sound/sound.rb +22 -0
- data/lib/opal/phaser/tween/easing.rb +10 -0
- data/lib/opal/phaser/tween/tween.rb +28 -2
- data/lib/opal/phaser/version.rb +1 -1
- data/opal-phaser.gemspec +5 -4
- metadata +26 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d94a97387570a6d4760d2fa61b4a1f5c3fe882e8
|
4
|
+
data.tar.gz: cdd24fbcb8e731c696f20b4db010d4403e8923e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba08bdafd287aba3028627ff375e4a68ee4b88b4b1478af8e8c3b9b3c5c67fa32aad4a0568cf3759abe269ba5a9dfe6022f1339237fc3f53b706870f475ba913
|
7
|
+
data.tar.gz: 4193b91baf5713d61734c5213ed0d68e24966ecba0878c293c823ce09b6e9995113f53d8dae0027ddbf6e02a0168d39fa34b444944812da68b4068c719bcb817
|
data/README.md
CHANGED
@@ -11,12 +11,20 @@ If you have not heard of Phaser, check out these links:
|
|
11
11
|
* Phaser: https://github.com/photonstorm/phaser
|
12
12
|
* Phaser Examples: https://github.com/photonstorm/phaser-examples
|
13
13
|
|
14
|
-
|
14
|
+
## Projects built with opal-phaser
|
15
15
|
|
16
|
-
|
16
|
+
### Examples
|
17
17
|
|
18
|
+
Phaser usage examples converted to Ruby: https://github.com/orbitalimpact/opal-phaser-examples.
|
19
|
+
|
20
|
+
### Games
|
21
|
+
|
22
|
+
Some of the games that have been made so far with opal-phaser:
|
23
|
+
|
24
|
+
* [Official demo](https://github.com/orbitalimpact/opal-phaser/tree/master/demo)
|
18
25
|
* [Flutterjump](https://github.com/orbitalimpact/flutterjump)
|
19
26
|
* [A pong clone](https://github.com/opengamedev/pong-opal-phaser)
|
27
|
+
* [Tankgame](https://github.com/tangentstorm/tankgame)
|
20
28
|
|
21
29
|
## Cloning this repository
|
22
30
|
|
data/demo/app/main.rb
CHANGED
@@ -89,7 +89,7 @@ class Platforms
|
|
89
89
|
|
90
90
|
def create_ground
|
91
91
|
ground = @platforms.create(0, @game.world.height - 64, @sprite_key)
|
92
|
-
ground.scale.
|
92
|
+
ground.scale.set(2, 2)
|
93
93
|
ground.body.immovable = true
|
94
94
|
end
|
95
95
|
|
@@ -161,9 +161,9 @@ class Game
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def run
|
164
|
-
game = Phaser::Game.new
|
165
|
-
state = MainLevel.new(game)
|
166
|
-
game.state.add(:main, state, true)
|
164
|
+
$game = Phaser::Game.new
|
165
|
+
state = MainLevel.new($game)
|
166
|
+
$game.state.add(:main, state, true)
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
data/demo/index.html
CHANGED
@@ -4,13 +4,14 @@
|
|
4
4
|
<meta charset= "utf-8" />
|
5
5
|
<title>Opal-Phaser</title>
|
6
6
|
<link rel="stylesheet" href="style.css">
|
7
|
-
<script src="//cdn.jsdelivr.net/phaser/2.
|
7
|
+
<script src="//cdn.jsdelivr.net/phaser/2.4.3/phaser.js"></script>
|
8
8
|
<script src="/assets/main.js"></script>
|
9
9
|
</head>
|
10
10
|
|
11
11
|
<body>
|
12
12
|
<script>
|
13
13
|
window.onload = function() {
|
14
|
+
Opal.load("main")
|
14
15
|
opal_game = Opal.Game.$new()
|
15
16
|
}
|
16
17
|
</script>
|
data/lib/opal/phaser.rb
CHANGED
@@ -16,13 +16,15 @@ module Phaser
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.generate_frame_names(args = {})
|
19
|
-
|
20
|
-
start_num = args[:start_num]
|
21
|
-
stop_num = args[:stop_num]
|
22
|
-
suffix = args[:suffix, ""]
|
23
|
-
zeros_padding = args[:zeros_padding, 0]
|
19
|
+
optional_args = {suffix: "", zeros_padding: 0}
|
24
20
|
|
25
|
-
|
21
|
+
optional_args.each do |optional_arg, default_value|
|
22
|
+
unless args.include?(optional_arg)
|
23
|
+
args[optional_arg] = default_value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
`Phaser.Animation.generateFrameNames(#{args[:prefix]}, #{args[:start_num]}, #{args[:stop_num]}, #{args[:suffix]}, #{args[:zeros_padding]})`
|
26
28
|
end
|
27
29
|
|
28
30
|
alias_native :is_playing?, :isPlaying
|
@@ -9,6 +9,8 @@ require 'opal/phaser/math/random_data_generator'
|
|
9
9
|
require 'opal/phaser/core/camera'
|
10
10
|
require 'opal/phaser/core/loader'
|
11
11
|
require 'opal/phaser/core/scale_manager'
|
12
|
+
require 'opal/phaser/pixi/web_gl_renderer'
|
13
|
+
require 'opal/pixi/canvas_renderer'
|
12
14
|
|
13
15
|
module Phaser
|
14
16
|
AUTO = `Phaser.AUTO`
|
@@ -54,12 +56,14 @@ module Phaser
|
|
54
56
|
#alias_native :time, :time, as: Time
|
55
57
|
alias_native :rnd, :rnd, as: RandomDataGenerator
|
56
58
|
alias_native :camera, :camera, as: Camera
|
57
|
-
alias_native :scale, :scale,
|
59
|
+
alias_native :scale, :scale, as: ScaleManager
|
58
60
|
|
59
61
|
alias_native :make, :make, as: GameObjectCreator
|
60
62
|
alias_native :load, :load, as: Loader
|
61
63
|
alias_native :debug
|
64
|
+
alias_native :device
|
62
65
|
alias_native :width
|
66
|
+
alias_native :height
|
63
67
|
alias_native :paused
|
64
68
|
alias_native :destroy
|
65
69
|
|
@@ -70,5 +74,17 @@ module Phaser
|
|
70
74
|
def paused=(bool)
|
71
75
|
`#@native.paused = bool`
|
72
76
|
end
|
77
|
+
|
78
|
+
def renderer
|
79
|
+
if `#@native.renderer instanceof PIXI.WebGLRenderer`
|
80
|
+
PIXI::WebGLRenderer.new(`#@native.renderer`)
|
81
|
+
else
|
82
|
+
PIXI::CanvasRenderer.new(`#@native.renderer`)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def is_booted?
|
87
|
+
`#@native.isBooted`
|
88
|
+
end
|
73
89
|
end
|
74
90
|
end
|
@@ -14,6 +14,7 @@ module Phaser
|
|
14
14
|
alias_native :spritesheet
|
15
15
|
alias_native :atlas
|
16
16
|
alias_native :start
|
17
|
+
alias_native :audio
|
17
18
|
|
18
19
|
alias_native :onFileComplete
|
19
20
|
alias_native :onFileError
|
@@ -24,7 +25,8 @@ module Phaser
|
|
24
25
|
alias_native :atlasJSONHash
|
25
26
|
alias_native :atlasXML
|
26
27
|
|
27
|
-
alias_native :
|
28
|
+
alias_native :set_preload_sprite, :setPreloadSprite
|
29
|
+
alias_native :cross_origin=, :crossOrigin
|
28
30
|
|
29
31
|
def cross_origin=(value)
|
30
32
|
`#@native.crossOrigin = #{value}`
|
@@ -6,6 +6,7 @@ require 'opal/phaser/game_objects/bitmap_data'
|
|
6
6
|
require 'opal/phaser/tween/tween'
|
7
7
|
require 'opal/phaser/game_objects/tile_sprite'
|
8
8
|
require 'opal/phaser/game_objects/button'
|
9
|
+
require 'opal/phaser/sound/sound'
|
9
10
|
|
10
11
|
module Phaser
|
11
12
|
class GameObjectFactory
|
@@ -19,5 +20,6 @@ module Phaser
|
|
19
20
|
alias_native :tween, :tween, as: Tween
|
20
21
|
alias_native :tile_sprite, :tileSprite, as: TileSprite
|
21
22
|
alias_native :button, :button, as: Button
|
23
|
+
alias_native :audio, :audio, as: Sound
|
22
24
|
end
|
23
25
|
end
|
@@ -1,24 +1,21 @@
|
|
1
1
|
require 'opal/phaser/core/anchor'
|
2
|
+
require 'opal/phaser/game_objects/events'
|
3
|
+
|
2
4
|
module Phaser
|
3
|
-
class Image
|
5
|
+
class Image < PIXI::Sprite
|
4
6
|
include Native
|
5
7
|
|
6
|
-
alias_native :x
|
7
|
-
alias_native :y
|
8
|
-
alias_native :x=
|
9
|
-
alias_native :y=
|
10
|
-
alias_native :height
|
11
|
-
alias_native :width
|
12
8
|
alias_native :input
|
9
|
+
alias_native :name
|
10
|
+
alias_native :kill
|
13
11
|
|
14
|
-
alias_native :
|
15
|
-
alias_native :destroy
|
16
|
-
|
17
|
-
alias_native :load_texture, :loadTexture
|
18
|
-
alias_native :anchor, :anchor, as: Anchor
|
12
|
+
alias_native :smoothed=
|
19
13
|
|
20
|
-
def
|
21
|
-
`#@native.
|
14
|
+
def input_enabled=(bool)
|
15
|
+
`#@native.inputEnabled = bool`
|
22
16
|
end
|
17
|
+
|
18
|
+
alias_native :load_texture, :loadTexture
|
19
|
+
alias_native :events, :events, as: Events
|
23
20
|
end
|
24
21
|
end
|
@@ -4,41 +4,28 @@ require 'opal/phaser/animation/animation_manager'
|
|
4
4
|
require 'opal/phaser/game_objects/events'
|
5
5
|
|
6
6
|
module Phaser
|
7
|
-
class Sprite
|
7
|
+
class Sprite < PIXI::Sprite
|
8
8
|
include Native
|
9
9
|
|
10
10
|
alias_native :key
|
11
|
-
alias_native :scale
|
12
11
|
alias_native :bounce
|
13
12
|
|
14
|
-
alias_native :kill
|
15
|
-
alias_native :destroy
|
16
13
|
alias_native :play
|
14
|
+
alias_native :crop
|
17
15
|
|
18
|
-
alias_native :visible=
|
19
16
|
alias_native :exists=
|
20
17
|
alias_native :alive=
|
21
18
|
alias_native :frame=
|
19
|
+
alias_native :smoothed=
|
22
20
|
|
23
|
-
alias_native :z
|
24
|
-
alias_native :z=
|
25
|
-
alias_native :x
|
26
|
-
alias_native :x=
|
27
|
-
alias_native :y
|
28
|
-
alias_native :y=
|
29
|
-
alias_native :width
|
30
|
-
alias_native :height
|
31
21
|
alias_native :right
|
32
22
|
|
23
|
+
alias_native :kill
|
33
24
|
|
34
25
|
def input_enabled=(bool)
|
35
26
|
`#@native.inputEnabled = bool`
|
36
27
|
end
|
37
28
|
|
38
|
-
def smoothed=(bool)
|
39
|
-
`#@native.smoothed = bool`
|
40
|
-
end
|
41
|
-
|
42
29
|
def frame_name=(name)
|
43
30
|
`#@native.frameName = name`
|
44
31
|
end
|
@@ -51,10 +38,13 @@ module Phaser
|
|
51
38
|
`#@native.checkWorldBounds = bool`
|
52
39
|
end
|
53
40
|
|
41
|
+
def update_crop
|
42
|
+
`#@native.updateCrop()`
|
43
|
+
end
|
44
|
+
|
54
45
|
alias_native :load_texture, :loadTexture
|
55
46
|
|
56
47
|
alias_native :body, :body, as: Physics::Arcade::Body
|
57
|
-
alias_native :anchor, :anchor, as: Anchor
|
58
48
|
alias_native :animations, :animations, as: AnimationManager
|
59
49
|
alias_native :events, :events, as: Events
|
60
50
|
|
@@ -1,9 +1,14 @@
|
|
1
1
|
module Phaser
|
2
|
-
class Rectangle
|
2
|
+
class Rectangle
|
3
3
|
include Native
|
4
4
|
|
5
|
-
def
|
6
|
-
`new Phaser.Rectangle(x, y, w, h)`
|
5
|
+
def initialize(x, y, w, h)
|
6
|
+
super `new Phaser.Rectangle(x, y, w, h)`
|
7
7
|
end
|
8
|
+
|
9
|
+
alias_native :x
|
10
|
+
alias_native :x=
|
11
|
+
alias_native :y
|
12
|
+
alias_native :y=
|
8
13
|
end
|
9
14
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Phaser
|
2
|
+
class Sound
|
3
|
+
include Native
|
4
|
+
|
5
|
+
def play(args = {})
|
6
|
+
arg_list = {marker: "", position: 0, volume: 1, loop: false, force_restart: true}
|
7
|
+
|
8
|
+
arg_list.each do |name, default_value|
|
9
|
+
unless args.include?(name)
|
10
|
+
args[name] = default_value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
`#@native.play(#{args[:marker]}, #{args[:position]}, #{args[:volume]}, #{args[:loop]}, #{args[:force_restart]})`
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_native :stop
|
18
|
+
alias_native :destroy
|
19
|
+
|
20
|
+
alias_native :fade_in, :fadeIn
|
21
|
+
end
|
22
|
+
end
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module Phaser
|
2
2
|
module Easing
|
3
|
+
def self.Default
|
4
|
+
`Phaser.Easing.Default`
|
5
|
+
end
|
6
|
+
|
3
7
|
module Quadratic
|
4
8
|
def self.In
|
5
9
|
`Phaser.Easing.Quadratic.In`
|
@@ -13,5 +17,11 @@ module Phaser
|
|
13
17
|
`Phaser.Easing.Quadratic.Out`
|
14
18
|
end
|
15
19
|
end
|
20
|
+
|
21
|
+
module Linear
|
22
|
+
def self.None
|
23
|
+
`Phaser.Easing.Linear.None`
|
24
|
+
end
|
25
|
+
end
|
16
26
|
end
|
17
27
|
end
|
@@ -1,8 +1,34 @@
|
|
1
1
|
module Phaser
|
2
2
|
class Tween
|
3
3
|
include Native
|
4
|
-
|
5
|
-
alias_native :to
|
4
|
+
|
6
5
|
alias_native :start
|
6
|
+
|
7
|
+
def to(args = {})
|
8
|
+
optional_args = {duration: 1000, ease: Phaser::Easing.Default, auto_start: false, delay: 0, repeat: 0, yoyo: false}
|
9
|
+
|
10
|
+
optional_args.each do |name, default_value|
|
11
|
+
unless args.include?(name)
|
12
|
+
args[name] = default_value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Tween.new `#@native.to(#{args[:properties].to_n}, #{args[:duration]}, #{args[:ease]}, #{args[:auto_start]}, #{args[:delay]}, #{args[:repeat]}, #{args[:yoyo]})`
|
17
|
+
end
|
18
|
+
|
19
|
+
def on(type, context = nil, &block)
|
20
|
+
case type.to_sym
|
21
|
+
when :child_complete
|
22
|
+
`#@native.onChildComplete.add(#{block.to_n}, #{context})`
|
23
|
+
when :complete
|
24
|
+
`#@native.onComplete.add(#{block.to_n}, #{context})`
|
25
|
+
when :loop
|
26
|
+
`#@native.onLoop.add(#{block.to_n}, #{context})`
|
27
|
+
when :repeat
|
28
|
+
`#@native.onRepeat.add(#{block.to_n}, #{context})`
|
29
|
+
when start
|
30
|
+
`#@native.onStart.add(#{block.to_n}, #{context})`
|
31
|
+
end
|
32
|
+
end
|
7
33
|
end
|
8
34
|
end
|
data/lib/opal/phaser/version.rb
CHANGED
data/opal-phaser.gemspec
CHANGED
@@ -6,16 +6,17 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.version = Opal::Phaser::VERSION
|
7
7
|
s.author = 'George Plymale'
|
8
8
|
s.email = 'george@orbitalimpact.com'
|
9
|
-
s.homepage = 'http://
|
10
|
-
s.summary = '
|
11
|
-
s.description = 'Opal
|
9
|
+
s.homepage = 'http://opalphaser.com'
|
10
|
+
s.summary = 'Ruby access to Phaser'
|
11
|
+
s.description = 'Opal wrapper library for the Phaser framework'
|
12
12
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.require_paths = ['lib']
|
17
17
|
|
18
|
-
s.add_runtime_dependency 'opal', '>= 0.
|
18
|
+
s.add_runtime_dependency 'opal', '>= 0.8.0', '<= 0.9.0'
|
19
|
+
s.add_runtime_dependency 'opal-pixi'
|
19
20
|
s.add_development_dependency 'opal-rspec', '~> 0.4.0'
|
20
21
|
s.add_development_dependency 'yard'
|
21
22
|
s.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-phaser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Plymale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -16,8 +16,8 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
20
|
-
- - "
|
19
|
+
version: 0.8.0
|
20
|
+
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.9.0
|
23
23
|
type: :runtime
|
@@ -26,10 +26,24 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
30
|
-
- - "
|
29
|
+
version: 0.8.0
|
30
|
+
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.9.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: opal-pixi
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: opal-rspec
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,7 +86,7 @@ dependencies:
|
|
72
86
|
- - ">="
|
73
87
|
- !ruby/object:Gem::Version
|
74
88
|
version: '0'
|
75
|
-
description: Opal
|
89
|
+
description: Opal wrapper library for the Phaser framework
|
76
90
|
email: george@orbitalimpact.com
|
77
91
|
executables: []
|
78
92
|
extensions: []
|
@@ -137,7 +151,10 @@ files:
|
|
137
151
|
- lib/opal/phaser/math/random_data_generator.rb
|
138
152
|
- lib/opal/phaser/physics/files.rb
|
139
153
|
- lib/opal/phaser/physics/physics.rb
|
154
|
+
- lib/opal/phaser/pixi/canvas_renderer.rb
|
155
|
+
- lib/opal/phaser/pixi/web_gl_renderer.rb
|
140
156
|
- lib/opal/phaser/setup.rb
|
157
|
+
- lib/opal/phaser/sound/sound.rb
|
141
158
|
- lib/opal/phaser/time/files.rb
|
142
159
|
- lib/opal/phaser/time/time.rb
|
143
160
|
- lib/opal/phaser/time/timer.rb
|
@@ -152,7 +169,7 @@ files:
|
|
152
169
|
- spec/html/index.html.erb
|
153
170
|
- spec/html/phaser.js
|
154
171
|
- spec/spec_helper.rb
|
155
|
-
homepage: http://
|
172
|
+
homepage: http://opalphaser.com
|
156
173
|
licenses: []
|
157
174
|
metadata: {}
|
158
175
|
post_install_message:
|
@@ -174,7 +191,7 @@ rubyforge_project:
|
|
174
191
|
rubygems_version: 2.4.5
|
175
192
|
signing_key:
|
176
193
|
specification_version: 4
|
177
|
-
summary:
|
194
|
+
summary: Ruby access to Phaser
|
178
195
|
test_files:
|
179
196
|
- spec/core/loader_spec.rb
|
180
197
|
- spec/html/index.html.erb
|