motion-game 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +120 -0
  3. data/build/android/armeabi/libmotion-cocos.a +0 -0
  4. data/build/android/motion-cocos.jar +0 -0
  5. data/build/android/x86/libmotion-cocos.a +0 -0
  6. data/build/ios/libmotion-cocos.a +0 -0
  7. data/build/tvos/libmotion-cocos.a +0 -0
  8. data/doc/API_reference.rb +1407 -0
  9. data/doc/MG.html +1 -1
  10. data/doc/MG/Action.html +9 -9
  11. data/doc/MG/Animate.html +4 -4
  12. data/doc/MG/Application.html +5 -5
  13. data/doc/MG/Audio.html +391 -175
  14. data/doc/MG/Blink.html +3 -3
  15. data/doc/MG/Button.html +23 -23
  16. data/doc/MG/Color.html +19 -20
  17. data/doc/MG/DelayTime.html +3 -3
  18. data/doc/MG/Director.html +33 -33
  19. data/doc/MG/Draw.html +11 -11
  20. data/doc/MG/Events.html +1 -1
  21. data/doc/MG/Events/Acceleration.html +17 -17
  22. data/doc/MG/Events/Touch.html +5 -5
  23. data/doc/MG/FadeIn.html +3 -3
  24. data/doc/MG/FadeOut.html +3 -3
  25. data/doc/MG/FadeTo.html +3 -3
  26. data/doc/MG/File.html +3 -3
  27. data/doc/MG/Follow.html +3 -3
  28. data/doc/MG/JumpBy.html +3 -3
  29. data/doc/MG/JumpTo.html +3 -3
  30. data/doc/MG/Layout.html +15 -15
  31. data/doc/MG/List.html +21 -21
  32. data/doc/MG/Menu.html +9 -9
  33. data/doc/MG/MoveBy.html +3 -3
  34. data/doc/MG/MoveTo.html +3 -3
  35. data/doc/MG/Node.html +61 -61
  36. data/doc/MG/Parallax.html +3 -3
  37. data/doc/MG/Particle.html +47 -47
  38. data/doc/MG/Point.html +16 -18
  39. data/doc/MG/Repeat.html +3 -3
  40. data/doc/MG/RepeatForever.html +3 -3
  41. data/doc/MG/RotateBy.html +3 -3
  42. data/doc/MG/RotateTo.html +3 -3
  43. data/doc/MG/ScaleBy.html +3 -3
  44. data/doc/MG/ScaleTo.html +3 -3
  45. data/doc/MG/Scene.html +33 -33
  46. data/doc/MG/Scroll.html +15 -15
  47. data/doc/MG/Sequence.html +3 -3
  48. data/doc/MG/Size.html +19 -20
  49. data/doc/MG/SkewBy.html +3 -3
  50. data/doc/MG/SkewTo.html +3 -3
  51. data/doc/MG/Slider.html +7 -7
  52. data/doc/MG/Spawn.html +3 -3
  53. data/doc/MG/Speed.html +3 -3
  54. data/doc/MG/Sprite.html +189 -67
  55. data/doc/MG/Text.html +31 -31
  56. data/doc/MG/TintBy.html +3 -3
  57. data/doc/MG/TintTo.html +3 -3
  58. data/doc/MG/Web.html +15 -15
  59. data/doc/MG/Widget.html +15 -15
  60. data/doc/_index.html +1 -1
  61. data/doc/file.README.html +4 -2
  62. data/doc/index.html +4 -2
  63. data/doc/method_list.html +181 -141
  64. data/doc/top-level-namespace.html +1 -1
  65. data/lib/motion-game/android.rb +0 -1
  66. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d99521187e1dd28218c16860e0f724701837f663
4
- data.tar.gz: bead34fe7ed7ca5116d1670452e116ec6eb29a27
3
+ metadata.gz: 9fb5bcabc0166c1bde03a269cfd020229aff8a07
4
+ data.tar.gz: abbbd7a9a720940f1215fcadb19a53ca13c9a098
5
5
  SHA512:
6
- metadata.gz: 27130eb08428559c6967ecb694d3f34d3131f8eaa7301463681318024bcb739968b4ebe49eed2be2ca64a7051b59446e0d50d9d81a2c464a79f4137ea4a74381
7
- data.tar.gz: b7d0efc945ffcd8776feb9627fac186a76b737b891025b0d815b7905fc4b549d282c5ba359777122ad16a9b39e86dcc77df23d3ef6775d7fd79cc85c0ed7ad49
6
+ metadata.gz: 3fa98786ace1a42fd4373f3c4b1681ed0f6252da86725ce8ad94a4661453ffcd382c46b614edf8e160cfea3a14a008cfcfd548f9fe041a82694683e09123de8b
7
+ data.tar.gz: 6c262b3fd8c9de5c0590926555885acf852d80627e43899dda6b0b64cdc6b6b661a501fa9930c7396824f83e13f4f91ae59b5aea4af1ee94bf965efb722951d8
data/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # motion-game
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/motion-game.svg)](https://badge.fury.io/rb/motion-game)
4
+
5
+ motion-game is a cross-platform mobile game engine for RubyMotion. It lets you write mobile games in Ruby for iOS, tvOS and Android.
6
+
7
+ motion-game is currently in **beta**. Please give it a try and report problems you find to us.
8
+
9
+ ## Features
10
+
11
+ * **Use Ruby :-)** motion-game exposes a pure Ruby API to write games for mobile devices. You can write a video game all in Ruby.
12
+ * **100% cross-platform**: motion-game projects are fully cross-platform for iOS, tvOS and Android. One codebase runs everywhere.
13
+ * **Fully-featured**: motion-game has audio, sprites, animations, particles, device sensors / events, scene graph / director, UI widgets, etc.
14
+ * **Solid foundations**: the motion-game API is implemented using popular and stable opensource libraries, such as [cocos2d-x](http://www.cocos2d-x.org/), [box2d](http://box2d.org/), and more. motion-game projects are also based on RubyMotion which offers portable Ruby runtimes for iOS and Android as well as static compilation of Ruby code.
15
+ * **Native compilation**: your Ruby code will be compiled into optimized native code for each platform you target. There is no interpreter and the original Ruby code will not be in the app.
16
+ * **Platform APIs access**: if you need it, you can call the entire set of public iOS, tvOS or Android APIs from Ruby code as well.
17
+
18
+ ## Getting Started
19
+
20
+ ### Installing RubyMotion
21
+
22
+ [RubyMotion 4.7+](http://rubymotion.com) is required. A starter version can be downloaded for free. You also need to set up your computer for mobile development (iOS and/or tvOS and/or Android). Follow the [Getting Started](http://rubymotion.com/developers) guides after installation.
23
+
24
+ ### Installing motion-game
25
+
26
+ #### Binaries
27
+
28
+ motion-game is available as a gem:
29
+
30
+ ```
31
+ $ gem install motion-game
32
+ ```
33
+
34
+ #### Source
35
+
36
+ You can build your own copy of motion-game:
37
+
38
+ - Make sure you have your system set up for Android develpment: `motion android-setup --api_version=16`.
39
+
40
+ ```
41
+ $ git clone https://github.com/HipByte/motion-game.git && cd motion-game
42
+ $ git submodule update --init
43
+ $ bundle
44
+ $ rake build:setup
45
+
46
+ $ rake gem
47
+ $ gem install motion-game-x.x.gem
48
+ ```
49
+
50
+ #### Developing Locally
51
+
52
+ Once you have the source locally. Create a motion-game project as a sibling to the `motion-game` directory using the `motion create --template=motion-game PROJECTNAME` command.
53
+
54
+ Update the reference to `motion-game` in your `Gemfile` to point to your local instance of `motion-game`:
55
+
56
+ gem 'motion-game', path: '../motion-game'
57
+
58
+ Chances are all of you changes will be done in the `/src` directory (since it'll probably be adding missing Cocos2dx methods).
59
+
60
+ Once you've made your change in the correct `.cpp` file, run `rake build:ios`/`rake build:android` to test your changes locally (running `rake gem` is a longer process which you don't have to do).
61
+
62
+ Here are some examples of how to add missing apis to motion-game:
63
+
64
+ - [add Draw#triange](https://github.com/HipByte/motion-game/commit/3c32771be11c5715a4922ba45914207b2c6f4d38)
65
+ - [add Draw#line](https://github.com/HipByte/motion-game/commit/972fd115d3ef2816c19618b14823363356ca85b1)
66
+ - [add Draw#clear](https://github.com/HipByte/motion-game/commit/98cc463724153bae1481a9364ef3f166e15f8c0f)
67
+
68
+ ### Hello World
69
+
70
+ ```
71
+ $ motion create --template=motion-game HelloWorld
72
+ $ cd HelloWorld
73
+ ```
74
+
75
+ #### iOS
76
+
77
+ ```
78
+ $ rake ios:simulator
79
+ $ rake ios:device
80
+ ```
81
+
82
+ #### tvOS
83
+
84
+ ```
85
+ $ rake tvos:simulator
86
+ $ rake tvos:device
87
+ ```
88
+
89
+ #### Android
90
+
91
+ ```
92
+ $ rake android:emulator
93
+ $ rake android:device
94
+ ```
95
+
96
+ ### API reference
97
+
98
+ The whole framework API is documented. The [API reference](http://www.rubydoc.info/gems/motion-game/) is available online.
99
+
100
+ You can also build the API reference locally:
101
+
102
+ ```
103
+ $ rake doc
104
+ $ open doc/index.html
105
+ ```
106
+
107
+ ### Samples
108
+
109
+ The [samples](https://github.com/HipByte/motion-game/tree/master/samples) directory contains sample projects.
110
+
111
+ ## License
112
+
113
+ Copyright (c) 2015, HipByte (info@hipbyte.com) and contributors. All rights reserved.
114
+
115
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
116
+
117
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
118
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
119
+
120
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,1407 @@
1
+ # CAUTION :
2
+ # This file is automatically generated to creating documents.
3
+ # Please not use this file for your app.
4
+ #--------------------------------------------------------------
5
+
6
+ # MG stands for Motion Game. All classes part of the framework are defined under that module.
7
+ module MG
8
+ # The MG::Events module contains classes that represent events received from the game engine. You typically never instantiate these classes yourself.
9
+ module Events; end
10
+
11
+ class Action < Object
12
+ # Reverses the action
13
+ # @return [Action] the reversed action.
14
+ def reverse; end
15
+
16
+ end
17
+
18
+ class Action < Object
19
+ # Clones the action
20
+ # @return [Action] the cloned action.
21
+ def clone; end
22
+
23
+
24
+ # @group Properties
25
+
26
+ # Whether the action is done.
27
+ # @return [Boolean] whether the action is done.
28
+ attr_accessor :done?
29
+
30
+ end
31
+
32
+ class MoveBy < Action
33
+
34
+ # @group Constructors
35
+
36
+ # Creates an action that will move the position of the receiver to a new location
37
+ # determined by the sum of the current location and the given +delta_location+ object.
38
+ # @param delta_location [Point] a point that will be added to the receiver's
39
+ # current location.
40
+ # @param interval [Float] the animation interval.
41
+ # @return [MoveBy] the action.
42
+ def initialize(delta_location, interval); end
43
+
44
+ end
45
+
46
+ class MoveTo < Action
47
+
48
+ # @group Constructors
49
+
50
+ # Creates an action that will move the position of the receiver to a new given location.
51
+ # @param location [Point] where the receiver should be moved to.
52
+ # @param interval [Float] the animation interval.
53
+ # @return [MoveTo] the action.
54
+ def initialize(location, interval); end
55
+
56
+ end
57
+
58
+ class JumpBy < Action
59
+
60
+ # @group Constructors
61
+
62
+ # Creates an action that will jump the receiver to a new location
63
+ # determined by the sum of the current location and the given +delta_location+ object.
64
+ # @param delta_location [Point] a point that will be added to the receiver's
65
+ # current location during jumping.
66
+ # @param height [Float] the height of the jump
67
+ # @param jumps [Float] the number of jumps
68
+ # @param interval [Float] the animation interval.
69
+ # @return [JumpBy] the action.
70
+ def initialize(delta_location, height, jumps, interval); end
71
+
72
+ end
73
+
74
+ class JumpTo < Action
75
+
76
+ # @group Constructors
77
+
78
+ # Creates an action that will jump the receiver to a new location.
79
+ # @param location [Point] a point that the receiver will jump to
80
+ # @param height [Float] the height of the jump
81
+ # @param jumps [Float] the number of jumps
82
+ # @param interval [Float] the animation interval.
83
+ # @return [JumpTo] the action.
84
+ def initialize(location, height, jumps, interval); end
85
+
86
+ end
87
+
88
+ class RotateBy < Action
89
+
90
+ # @group Constructors
91
+
92
+ # Creates an action that will rotates the position of the receiver
93
+ # to a new angle determined by the
94
+ # sum of the current rotation and the given +delta_angle+ object.
95
+ # @param delta_angle [Float] the angle to add to the current rotation
96
+ # @param interval [Float] the animation interval.
97
+ # @return [Sprite] the receiver.
98
+ def initialize(delta_angle, interval); end
99
+
100
+ end
101
+
102
+ class RotateTo < Action
103
+
104
+ # @group Constructors
105
+
106
+ # Creates an action that will rotate the angle of the receiver to a new angle
107
+ # by modifying it's rotation attribute.
108
+ # @param angle [Float] the receiver should be rotated to.
109
+ # @param interval [Float] the animation interval.
110
+ # @return [RotateTo] the action.
111
+ def initialize(angle, interval); end
112
+
113
+ end
114
+
115
+ class ScaleBy < Action
116
+
117
+ # @group Constructors
118
+
119
+ # Creates an action that will scale the receiver
120
+ # @param scale [Float] the receiver should be scaled by
121
+ # @param interval [Float] the animation interval.
122
+ # @return [ScaleBy] the action.
123
+ def initialize(scale, interval); end
124
+
125
+ end
126
+
127
+ class ScaleTo < Action
128
+
129
+ # @group Constructors
130
+
131
+ # Creates an action that will scale the receiver
132
+ # @param scale [Float] the receiver should be scaled to
133
+ # @param interval [Float] the animation interval.
134
+ # @return [ScaleTo] the action.
135
+ def initialize(scale, interval); end
136
+
137
+ end
138
+
139
+ class SkewBy < Action
140
+
141
+ # @group Constructors
142
+
143
+ # Creates an action that skews a Node object to given angles by modifying it's
144
+ # skewX and skewY attributes by delta_x_angle and delta_y_angle.
145
+ # @param delta_x_angle [Float] the skew X delta angle
146
+ # @param delta_y_angle [Float] the skew Y delta angle
147
+ # @param interval [Float] the animation interval.
148
+ # @return [SkewBy] the action.
149
+ def initialize(delta_x_angle, delta_y_angle, interval); end
150
+
151
+ end
152
+
153
+ class SkewTo < Action
154
+
155
+ # @group Constructors
156
+
157
+ # Creates an action that skews a Node object to given angles by modifying it's
158
+ # skewX and skewY attributes
159
+ # @param x_angle [Float] the Skew X Angle
160
+ # @param y_angle [Float] the Skew Y Angle
161
+ # @param interval [Float] the animation interval.
162
+ # @return [SkewTp] the action.
163
+ def initialize(x_angle, y_angle, interval); end
164
+
165
+ end
166
+
167
+ class TintBy < Action
168
+
169
+ # @group Constructors
170
+
171
+ # Creates an action that tints a Node from current tint to a custom one.
172
+ # @param delta_red [Float]
173
+ # @param delta_green [Float]
174
+ # @param delta_blue [Float]
175
+ # @param interval [Float] the animation interval.
176
+ # @return [TintBy] the action.
177
+ def initialize(delta_red, delta_green, delta_blue, interval); end
178
+
179
+ end
180
+
181
+ class TintTo < Action
182
+
183
+ # @group Constructors
184
+
185
+ # Creates an action that tints the receiver from its current tint to a custom one.
186
+ # @param red [Float]
187
+ # @param green [Float]
188
+ # @param blue [Float]
189
+ # @param interval [Float] the animation interval.
190
+ # @return [TintTo] the action.
191
+ def initialize(red, green, blue, interval); end
192
+
193
+ end
194
+
195
+ class FadeTo < Action
196
+
197
+ # @group Constructors
198
+
199
+ # Creates an action Fades the receiver. It modifies the opacity from the current opacity
200
+ # to a custom one.
201
+ # @param opacity [Integer] the opacity to fade the object to (between 0-255)
202
+ # @param interval [Float] the animation interval.
203
+ # @return [FadeTo] the action.
204
+ def initialize(opacity, interval); end
205
+
206
+ end
207
+
208
+ class FadeIn < Action
209
+
210
+ # @group Constructors
211
+
212
+ # Creates an action Fades In the receiver. It modifies the opacity from the 0 to 255.
213
+ # @param interval [Float] the animation interval.
214
+ # @return [FadeIn] the action.
215
+ def initialize(interval); end
216
+
217
+ end
218
+
219
+ class FadeOut < Action
220
+
221
+ # @group Constructors
222
+
223
+ # Creates an action Fades Out the receiver. It modifies the opacity from the 255 to 0.
224
+ # @param interval [Float] the animation interval.
225
+ # @return [FadeOut] the action.
226
+ def initialize(interval); end
227
+
228
+ end
229
+
230
+ class Blink < Action
231
+
232
+ # @group Constructors
233
+
234
+ # Creates an action that Blinks the receiver by modifying it's visible attribute.
235
+ # @param blinks [Integer] the number of times to blink.
236
+ # @param interval [Float] the animation interval.
237
+ # @return [Blink] the action.
238
+ def initialize(blinks, interval); end
239
+
240
+ end
241
+
242
+ class Sequence < Action
243
+
244
+ # @group Constructors
245
+
246
+ # Creates an action that runs actions sequentially,
247
+ # one after another on the receiver.
248
+ # @param actions [Action[]] the array of actions to run in sequence
249
+ # @return [Sequence] the action.
250
+ def initialize(actions); end
251
+
252
+ end
253
+
254
+ class Spawn < Action
255
+
256
+ # @group Constructors
257
+
258
+ # Creates an action that spawns actions in parallel on the receiver.
259
+ # @param actions [Action[]] the array of actions to run
260
+ # @return [Spawn] the action.
261
+ def initialize(actions); end
262
+
263
+ end
264
+
265
+ class Follow < Action
266
+
267
+ # @group Constructors
268
+
269
+ # Creates an action that sets up the receiver to follow the 'followed node'.
270
+ # @param followed_node [Node] the node to follow
271
+ # @return [Follow] the action.
272
+ def initialize(followed_node); end
273
+
274
+ end
275
+
276
+ class DelayTime < Action
277
+
278
+ # @group Constructors
279
+
280
+ # Creates an action that delays the action a certain amount of seconds.
281
+ # @param interval [Float] the interval to delay.
282
+ # @return [DelayTime] the action.
283
+ def initialize(interval); end
284
+
285
+ end
286
+
287
+ class Speed < Action
288
+
289
+ # @group Constructors
290
+
291
+ # Changes the speed of an action, making it take longer (speed>1)
292
+ # or less (speed<1) time. Useful to simulate 'slow motion' or 'fast forward' effect.
293
+ # ** This action can't be Sequenceable because it is not an IntervalAction.
294
+ # @param target_action [Action] the action to adjust the speed of
295
+ # @param speed [Float] the adjustment to make to the speed (>1 longer, <1 shorter).
296
+ # @return [Speed] the action.
297
+ def initialize(target_action, speed); end
298
+
299
+ end
300
+
301
+ class Repeat < Action
302
+
303
+ # @group Constructors
304
+
305
+ # Creates an action that repeats the provided action a certain number of times.
306
+ # @param target_action [Action] the action to repeat.
307
+ # @param times [Integer] the number of times to repeat.
308
+ # @return [Repeat] the action.
309
+ def initialize(target_action, times); end
310
+
311
+ end
312
+
313
+ class RepeatForever < Action
314
+
315
+ # @group Constructors
316
+
317
+ # Creates an action that repeats the provided action forever.
318
+ # @param target_action [Action] the action to repeat.
319
+ # @return [RepeatForever] the action.
320
+ def initialize(target_action); end
321
+
322
+ end
323
+
324
+ class Animate < Action
325
+
326
+ # @group Constructors
327
+
328
+ # Creates an animation action where the sprite display frame will be changed to
329
+ # the given frames in +frame_names+ based on the given +delay+ and
330
+ # repeated +loops+ times.
331
+ # @param frame_names [Array<String>] an array of sprite frames to load and
332
+ # use for the animation, which can be either the names of standalone image
333
+ # files in the application's resource directory or the names of sprite
334
+ # frames loaded from a spritesheet using {Sprite.load}.
335
+ # @param delay [Float] the delay in seconds between each frame animation.
336
+ # @param loops [Integer, Symbol] the number of times the animation should
337
+ # loop. If given the +:forever+ symbol, the animation will loop forever.
338
+ # @return [Animate] the action.
339
+ def initialize(frame_names, delay, loops=1); end
340
+
341
+ end
342
+ # The application class. A proper subclass is generated for you by the
343
+ # project template with a {#start} method, in which you are responsible
344
+ # to create a scene and ask the director to run it:
345
+ # class Application < MG::Application
346
+ # def start
347
+ # MG::Director.shared.run(MyScene.new)
348
+ # end
349
+ # end
350
+ class Application < Object
351
+
352
+ # @group Constructors
353
+
354
+ # @return [Application] the shared Application instance.
355
+ def self.shared; end
356
+
357
+
358
+ # @group Entry Point
359
+
360
+ # This method is called when the application finished launching. This method
361
+ # is empty by default, and you are responsible to provide a custom
362
+ # implementation that will create the interface of your game.
363
+ # @return [Application] the receiver.
364
+ def start; end
365
+
366
+ end
367
+
368
+ class Audio < Object
369
+
370
+ # @group Constructors
371
+
372
+ # Creates a new Audio object based on a sound file at the given path and
373
+ # immediately plays it.
374
+ # @param path [String] the path of the sound file that should be played.
375
+ # @param loop [Boolean] whether the sound file playback should loop.
376
+ # @param volume [Float] the audio volume that should be used to play this
377
+ # this sound file, as a +0.0+ to +1.0+ Float range.
378
+ # @return [Audio] an Audio instance.
379
+ def self.play(path, loop=false, volume=1.0); end
380
+
381
+
382
+ # @group Instance Method Summary
383
+
384
+ # @return [Boolean] whether the sound file should loop.
385
+ def loop?; end
386
+
387
+ # Set whether to loop the sound.
388
+ # @param value [Boolean] true if the sound should loop.
389
+ def loop=(value); end
390
+
391
+ # @return [Float] the volume of the sound file, from a 0.0 to 1.0 Float range.
392
+ def volume; end
393
+
394
+ # Set the volume of the sound.
395
+ # @param value [Float] the volume of the sound.
396
+ def volume=(value); end
397
+
398
+ # @return [Float] the position where to play the sound file.
399
+ def current_position; end
400
+
401
+ # Set the position where to play the sound.
402
+ # @param value [Float] the position
403
+ def current_position=(value); end
404
+
405
+
406
+ # @group Properties
407
+
408
+ # @return [Float] the duration left in the sound file.
409
+ attr_reader :duration
410
+
411
+
412
+ # @group Instance Method Summary
413
+
414
+ # Resumes playing the sound file.
415
+ # @return [Audio] the receiver.
416
+ def resume; end
417
+
418
+ # Pauses the sound file.
419
+ # @return [Audio] the receiver.
420
+ def pause; end
421
+
422
+ # Stops the sound file.
423
+ # @return [Audio] the receiver.
424
+ def stop; end
425
+
426
+ # @return [Boolean] whether the sound file is being played.
427
+ def playing?; end
428
+
429
+ # @return [Boolean] whether the sound file is being paused.
430
+ def paused?; end
431
+
432
+ end
433
+ # Director is a shared object that takes care of the scene graph.
434
+ class Director < Object
435
+
436
+ # @group Constructors
437
+
438
+ # @return [Director] the shared Director instance.
439
+ def self.shared; end
440
+
441
+
442
+ # @group Managing Scenes
443
+
444
+ # Runs the given scene object.
445
+ # @param scene [Scene] the scene to run.
446
+ # @return [Director] the receiver.
447
+ def run(scene); end
448
+
449
+ # Replaces the current scene with a new one. The running scene will be
450
+ # terminated.
451
+ # @param scene [Scene] the scene to replace the current one with.
452
+ # @return [Director] the receiver.
453
+ def replace(scene); end
454
+
455
+ # Suspends the execution of the running scene, and starts running the given
456
+ # scene instead.
457
+ # @param scene [Scene] the new scene to run.
458
+ # @return [Director] the receiver.
459
+ def push(scene); end
460
+
461
+ # Pops the running scene from the stack, and starts running the previous
462
+ # scene. If there are no more scenes to run, the execution will be stopped.
463
+ # @return [Director] the receiver.
464
+ def pop; end
465
+
466
+ # Ends the execution of the running scene.
467
+ # @return [Director] the receiver.
468
+ def end; end
469
+
470
+ # Pauses the execution of the running scene.
471
+ # @return [Director] the receiver.
472
+ def pause; end
473
+
474
+ # Resumes the execution of the current paused scene.
475
+ # @return [Director] the receiver.
476
+ def resume; end
477
+
478
+ # The main loop is triggered again.
479
+ # @return [Director] the receiver.
480
+ def start_animation; end
481
+
482
+ # Stops the animation.
483
+ # @return [Director] the receiver.
484
+ def stop_animation; end
485
+
486
+
487
+ # @group Properties
488
+
489
+ # @return [Point] the visible origin of the director view in points.
490
+ attr_reader :origin
491
+
492
+ # @return [Size] the visible size of the director view in points.
493
+ attr_reader :size
494
+
495
+ # Controls whether the FPS (frame-per-second) statistic label is displayed
496
+ # in the bottom-left corner of the director view. By default it is hidden.
497
+ # @return [Boolean] whether the FPS label is displayed.
498
+ attr_accessor :show_stats?
499
+
500
+ end
501
+ # This class represents an event received from the accelerometer sensor of
502
+ # the device, usually from the {Scene#on_accelerate} method.
503
+ class Events::Acceleration < Object
504
+
505
+ # @group Properties
506
+
507
+ # @return [Float] the x coordinate of the acceleration event.
508
+ attr_reader :x
509
+
510
+ # @return [Float] the y coordinate of the acceleration event.
511
+ attr_reader :y
512
+
513
+ # @return [Float] the z coordinate of the acceleration event.
514
+ attr_reader :z
515
+
516
+ # @return [Float] the timestamp of the acceleration event.
517
+ attr_reader :timestamp
518
+
519
+ end
520
+ # This class represents a touch event receive from the device, usually from
521
+ # the {Scene#on_touch_begin} method.
522
+ class Events::Touch < Object
523
+
524
+ # @group Properties
525
+
526
+ # @return [Point] the current location of the touch event.
527
+ attr_reader :location
528
+
529
+ end
530
+
531
+ class File
532
+ # Open a file and return its content
533
+ # @return [String] the content.
534
+ def self.read; end
535
+
536
+ end
537
+ # This class represents a scene, an independent screen or stage of the
538
+ # application workflow. A scene is responsible for handling events from the
539
+ # device, providing a physics world for the sprites, and also starting the
540
+ # game loop.
541
+ # An application must have at least one scene, and the +Scene+ class is
542
+ # designed to be subclassed.
543
+ class Scene < Node
544
+
545
+ # @group Constructors
546
+
547
+ # The default initializer. Subclasses can construct the scene interface in
548
+ # this method, as well as providing an implementation for {#update}, then
549
+ # run the update loop by calling {#start_update}.
550
+ # @return [Scene] the receiver.
551
+ def initialize; end
552
+
553
+
554
+ # @group Update Loop
555
+
556
+ # Starts the update loop. The +#update+ method will be called on this object
557
+ # for every frame.
558
+ # @return [Scene] the receiver.
559
+ def start_update; end
560
+
561
+ # Stops the update loop. The +#update+ method will no longer be called on
562
+ # this object.
563
+ # @return [Scene] the receiver.
564
+ def stop_update; end
565
+
566
+ # The update loop method. Subclasses can provide a custom implementation of
567
+ # this method. The default implementation is empty.
568
+ # @param delta [Float] a value representing the amount of time, in seconds,
569
+ # since the last time this method was called.
570
+ # @return [Scene] the receiver.
571
+ def update(delta); end
572
+
573
+ # Schedules a given block for execution.
574
+ # @param delay [Float] the duration of the block, in seconds.
575
+ # @param repeat [Integer] the number of times the block should be repeated.
576
+ # @param interval [Float] the interval between repetitions, in seconds.
577
+ # @yield [Float] the given block will be yield with the delta value,
578
+ # in seconds.
579
+ # @return [String] a token representing the task that can be passed to
580
+ # {#unschedule} when needed.
581
+ def schedule(delay, repeat=0, interval=0); end
582
+
583
+ # Unschedules a task that's currently running.
584
+ # @param key [String] a token representing the task to unschedule,
585
+ # returned by {#schedule}.
586
+ # @return [Scene] the receiver.
587
+ def unschedule(key); end
588
+
589
+
590
+ # @group Events
591
+
592
+ # Starts listening for touch begin events on the receiver.
593
+ # @yield [Events::Touch] the given block will be yield when a touch begin
594
+ # event is received.
595
+ # @return [Scene] the receiver.
596
+ def on_touch_begin; end
597
+
598
+ # Starts listening for touch end events on the receiver.
599
+ # @yield [Events::Touch] the given block will be yield when a touch end
600
+ # event is received.
601
+ # @return [Scene] the receiver.
602
+ def on_touch_end; end
603
+
604
+ # Starts listening for touch move events on the receiver.
605
+ # @yield [Events::Touch] the given block will be yield when a touch move
606
+ # event is received.
607
+ # @return [Scene] the receiver.
608
+ def on_touch_move; end
609
+
610
+ # Starts listening for touch cancel events on the receiver.
611
+ # @yield [Events::Touch] the given block will be yield when a touch cancel
612
+ # event is received.
613
+ # @return [Scene] the receiver.
614
+ def on_touch_cancel; end
615
+
616
+ # Starts listening for accelerometer events on the receiver.
617
+ # @yield [Events::Acceleration] the given block will be yield when an
618
+ # accelerometer event is received from the device.
619
+ # @return [Scene] the receiver.
620
+ def on_accelerate; end
621
+
622
+ # Starts listening for contact begin events from the physics engine.
623
+ # @yield [Events::PhysicsContact] the given block will be yield when a
624
+ # contact event is received from the physics engine.
625
+ # @return [Scene] the receiver.
626
+ def on_contact_begin; end
627
+
628
+
629
+ # @group Properties
630
+
631
+ # @return [Point] the gravity of the scene's physics world.
632
+ attr_accessor :gravity
633
+
634
+ # @return [Boolean] whether the physics engine should draw debug lines.
635
+ attr_accessor :debug_physics?
636
+
637
+ end
638
+ # A Menu is a way to navigate through game options.
639
+ # Menus often contain options like Play, Quit, Settings and About.
640
+ # This is usually in the form of buttons that are pressed.
641
+ class Menu < Object
642
+
643
+ # @group Miscellaneous
644
+
645
+ # aligns menu items vertically with padding
646
+ # (call after adding items via image_item)
647
+ # @param padding [Float] the amount of padding between the items.
648
+ # @return [Menu] the receiver.
649
+ def align_items_vertically(padding=null); end
650
+
651
+ # aligns menu items horizontally with padding
652
+ # (call after adding items via image_item)
653
+ # @param padding [Float] the amount of padding between the items.
654
+ # @return [Menu] the receiver.
655
+ def align_items_horizontally(padding=null); end
656
+
657
+
658
+ # @group Properties
659
+
660
+ # Whether the menu is enabled. When enabled, a menu can be
661
+ # touched or clicked. By default, a menu is enabled.
662
+ # @return [Boolean] whether the menu is enabled.
663
+ attr_accessor :enabled?
664
+
665
+ end
666
+ # Node is the base class of objects in the scene graph. You should not
667
+ # instantiate this class directly but use a subclass instead.
668
+ class Node < Object
669
+
670
+ # @group Properties
671
+
672
+ # The anchor point of the node, as a set of percentage coordinates.
673
+ # The anchor point represents where the node will be attached to its parent,
674
+ # and is normalized as a percentage. +[0, 0]+ means the bottom-left corner,
675
+ # and +[1, 1]+ the top-right corner. You can also use values lower than +0+
676
+ # and higher than +1+. The default anchor point value is +[0.5, 0.5]+, which
677
+ # means the center of the parent.
678
+ # @return [Point] the anchor point of the node.
679
+ attr_accessor :anchor_point
680
+
681
+ # @return [Point] the +[x, y]+ position of the node in its parent's
682
+ # coordinate system.
683
+ attr_accessor :position
684
+
685
+ # @return [Size] the content size of the node.
686
+ attr_accessor :size
687
+
688
+ # @return [Boolean] whether the node should be visible. The default value is
689
+ # true.
690
+ attr_accessor :visible?
691
+
692
+ # @return [Float] the opacity (alpha) level of the node, as a Float from the
693
+ # +0.0+ to +1.0+ range.
694
+ attr_accessor :alpha
695
+
696
+ # @return [Integer] the local z-order index of the receiver in the scene
697
+ # graph, which will determine its priority when rendering the scene.
698
+ attr_accessor :z_index
699
+
700
+ # @return [Color] the color of the node.
701
+ attr_accessor :color
702
+
703
+ # Returns the rotation of the node in degrees. 0 is the default angle.
704
+ # Positive values rotate node clockwise, and negative values for
705
+ # anti-clockwise
706
+ # @return [Float] the rotation of the node in degrees.
707
+ attr_accessor :rotation
708
+
709
+ # Returns the scaling factor of the node, which multiplies its width, height
710
+ # and depth.
711
+ # @return [Float] the scaling factor.
712
+ attr_accessor :scale
713
+
714
+ # @return [String] a name to easily identify the node in the graph.
715
+ attr_accessor :name
716
+
717
+
718
+ # @group Miscellaneous
719
+
720
+ # Run the provided action on the receiver node.
721
+ # @return [Node] the receiver.
722
+ def run_action(action); end
723
+
724
+ # Stop all actions running on the node
725
+ # @return [Node] the receiver.
726
+ def stop_all_actions(); end
727
+
728
+ # Stop the provided action
729
+ # @param action [Action] the action to stop.
730
+ # @return [Node] the receiver.
731
+ def stop_action(action); end
732
+
733
+ # @param node [Node] a given Node object.
734
+ # @return [Boolean] whether the receiver's bounding box intersects with the
735
+ # given node's bounding box.
736
+ def intersects?(node); end
737
+
738
+
739
+ # @group Container
740
+
741
+ # Adds a child node to the receiver with a local z-order.
742
+ # @param node [Node] the child to add.
743
+ # @param zpos [Integer] the local z-order.
744
+ # @return [Node] the receiver.
745
+ def add(node, zpos=0); end
746
+
747
+ # Removes all children nodes from the receiver.
748
+ # @param cleanup [Boolean] cleans all running actions on children before
749
+ # removing them.
750
+ # @return [Node] the receiver.
751
+ def clear(cleanup=true); end
752
+
753
+ # Removes the given child node from the receiver.
754
+ # @param cleanup [Boolean] cleans all running actions on child before
755
+ # removing it.
756
+ # @return [Node] the receiver.
757
+ def delete(node, cleanup=true); end
758
+
759
+ # @return [Node] the parent node, or +nil+ if there isn't one.
760
+ def parent; end
761
+
762
+ # @return [Array<Node>] an array of +Node+ objects that have been added to
763
+ # the receiver.
764
+ def children; end
765
+
766
+ # Removes the receiver node from its parent.
767
+ # Same as:
768
+ # node.parent.delete(node, cleanup)
769
+ # @param cleanup [Boolean] cleans all running actions on the receiver before
770
+ # removing it from the parent.
771
+ # @return [Node] the receiver.
772
+ def delete_from_parent(cleanup=true); end
773
+
774
+ end
775
+
776
+ class Parallax < Node
777
+ # Adds the given Node object to the receiver and configure it in the
778
+ # parallax view.
779
+ # @param node [Node] the node to add to the receiver.
780
+ # @param zpos [Integer] the local z-order.
781
+ # @param parallax_ratio [Point]
782
+ # @param position_offset [Point]
783
+ # @return [Node] the child node.
784
+ def add(node, zpos, parallax_ratio, position_offset); end
785
+
786
+ end
787
+
788
+ class Draw < Node
789
+
790
+ # @group Draw Operations
791
+
792
+ # Clears drew shapes.
793
+ # @return [Draw] the receiver.
794
+ def clear; end
795
+
796
+ # Draws a filled circle at the given position with the given radius and color.
797
+ # @param pos [Point] the position where to draw.
798
+ # @param radius [Float] the radius of the circle to draw.
799
+ # @param color [Color] the color to use to fill the circle.
800
+ # @return [Draw] the receiver.
801
+ def dot(pos, radius, color); end
802
+
803
+ # Draws a rectangle at the given position with the given color.
804
+ # @param origin [Point] the position where to start drawing (lower-left).
805
+ # @param destination [Point] the position where to end drawing (higher-right).
806
+ # @param color [Color] the color to use to draw.
807
+ # @param fill [Boolean] whether the rectangle should be filled up.
808
+ # @return [Draw] the receiver.
809
+ def rect(origin, destination, color, fill=false); end
810
+
811
+ # Draws a line at the given position with the given color.
812
+ # @param origin [Point] the position where to start drawing (lower-left).
813
+ # @param destination [Point] the position where to end drawing (higher-right).
814
+ # @param thickness [Float] the line thickness.
815
+ # @param color [Color] the color to use to draw.
816
+ # @return [Draw] the receiver.
817
+ def line(origin, destination, thickness, color); end
818
+
819
+ # Draws a triangle at the given positions with the given color.
820
+ # @param position1 [Point] The triangle vertex point.
821
+ # @param position2 [Point] The triangle vertex point.
822
+ # @param position3 [Point] The triangle vertex point.
823
+ # @param color [Color] the color to use to draw.
824
+ # @return [Draw] the receiver.
825
+ def triangle(position1, position2, position3, color); end
826
+
827
+ end
828
+
829
+ class Particle < Node
830
+
831
+ # @group Constructors
832
+
833
+ # Creates a Particle object. If +file_name+ is given, it should be the name
834
+ # files can be created manually or with a visual editor such as Particle
835
+ # Designer. If +file_name+ is not given an empty Particle object will be
836
+ # created.
837
+ # @param file_name [String] the name of the property list particle file.
838
+ def initialize(file_name=nil); end
839
+
840
+
841
+ # @group Properties
842
+
843
+ # @return [String] the path of the texture file.
844
+ attr_writer :texture
845
+
846
+ # @return [Float] the speed of the particle emitter.
847
+ attr_accessor :speed
848
+
849
+ # @return [Float] the life of each particle.
850
+ attr_accessor :life
851
+
852
+ # @return [Float] the life variation of each particle.
853
+ attr_accessor :life_range
854
+
855
+ # @return [Float] the angle of each particle.
856
+ attr_accessor :angle
857
+
858
+ # @return [Float] the angle variation of each particle.
859
+ attr_accessor :angle_range
860
+
861
+ # @return [Float] the duration of the particle.
862
+ attr_accessor :duration
863
+
864
+ # @return [Point] the position variation of each particle.
865
+ attr_accessor :position_range
866
+
867
+ # @return [Integer] the number of particles to emit.
868
+ attr_accessor :particle_count
869
+
870
+ # @return [Color] the color that should be used when the particle starts.
871
+ attr_accessor :start_color
872
+
873
+ # @return [Color] the color that should be used when the particle ends.
874
+ attr_accessor :end_color
875
+
876
+ end
877
+
878
+ class Sprite < Node
879
+
880
+ # @group Spritesheets
881
+
882
+ # Loads all sprites from the content of +file_name+, which should be
883
+ # the name of a property list spritesheet file in the application's resource
884
+ # directory. Once a spritesheet file is loaded, individual sprites can be
885
+ # created using {Sprite#initialize} by providing the name of the frame.
886
+ # Sprite frames files can be created with a visual editor such as
887
+ # TexturePacker.
888
+ # @param file_name [String] the name of the sprite frames property list file.
889
+ # @return [nil]
890
+ def self.load(file_name); end
891
+
892
+
893
+ # @group Constructors
894
+
895
+ # Creates a new sprite object from +sprite_name+, which must be either the
896
+ # name of a standalone image file in the application's resource directory
897
+ # or the name of a sprite frame which was loaded from a spritesheet using
898
+ # {load}.
899
+ # @param sprite_name [String] the name of the sprite to create.
900
+ def initialize(sprite_name); end
901
+
902
+
903
+ # @group Actions
904
+
905
+ # Moves the position of the receiver to a new location determined by the
906
+ # sum of the current location and the given +delta_location+ object.
907
+ # @param delta_location [Point] a point that will be added to the receiver's
908
+ # current location.
909
+ # @param interval [Float] the animation interval.
910
+ # @return [Sprite] the receiver.
911
+ def move_by(delta_location, interval); end
912
+
913
+ # Moves the position of the receiver to a new given location.
914
+ # @param location [Point] where the receiver should be moved to.
915
+ # @param interval [Float] the animation interval.
916
+ # @return [Sprite] the receiver.
917
+ def move_to(location, interval); end
918
+
919
+ # Rotates the position of the receiver to a new angle determined by the
920
+ # sum of the current rotation and the given +delta_angle+ object.
921
+ # @param delta_angle [Float] the angle to add to the current rotation
922
+ # @param interval [Float] the animation interval.
923
+ # @return [Sprite] the receiver.
924
+ def rotate_by(delta_angle, interval); end
925
+
926
+ # Rotates the angle of the receiver to a new angle certain angle
927
+ # by modifying it's rotation attribute.
928
+ # @param angle [Float] the receiver should be rotated to.
929
+ # @param interval [Float] the animation interval.
930
+ # @return [Sprite] the receiver.
931
+ def rotate_to(angle, interval); end
932
+
933
+ # Blinks the receiver.
934
+ # @param number_of_blinks [Integer] the number of times the receiver should
935
+ # blink.
936
+ # @param interval [Float] the animation interval.
937
+ # @return [Sprite] the receiver.
938
+ def blink(number_of_blinks, interval); end
939
+
940
+ # Starts an animation where the sprite display frame will be changed to
941
+ # the given frames in +sprite_frames_names+ based on the given +delay+ and
942
+ # repeated +loops+ times.
943
+ # @param frame_names [Array<String>] an array of sprite frames to load and
944
+ # use for the animation, which can be either the names of standalone image
945
+ # files in the application's resource directory or the names of sprite
946
+ # frames loaded from a spritesheet using {load}.
947
+ # @param delay [Float] the delay in seconds between each frame animation.
948
+ # @param loops [Integer, Symbol] the number of times the animation should
949
+ # loop. If given the +:forever+ symbol, the animation will loop forever.
950
+ # @return [Sprite] the receiver.
951
+ def animate(frame_names, delay, loops=1); end
952
+
953
+ # Sets whether the sprite should be flipped horizontally or not. It only flips
954
+ # the texture of the sprite, and not the texture of the sprite's children.
955
+ # Also, flipping the texture doesn't alter the anchorPoint.
956
+ # @param value [Boolean] true if the sprite should be flipped horizontally, false otherwise.
957
+ def flipped_horizontally=(value); end
958
+
959
+ # This is alias method of "#flipped_horizontally=".
960
+ def flipped_x=(value); end
961
+
962
+ # Sets whether the sprite should be flipped vertically or not. It only flips
963
+ # the texture of the sprite, and not the texture of the sprite's children.
964
+ # Also, flipping the texture doesn't alter the anchorPoint.
965
+ # @param value [Boolean] true if the sprite should be flipped vertically, false otherwise.
966
+ def flipped_vertically=(value); end
967
+
968
+ # This is alias method of "#flipped_vertically=".
969
+ def flipped_y=(value); end
970
+
971
+
972
+ # @group Physics
973
+
974
+ # Attaches a physics body with a box shape to the sprite.
975
+ # @param size [Size] the size of the box. If +nil+ is given, the size of the
976
+ # sprite, retrieved with {#size}, will be used instead.
977
+ # @return [Sprite] the receiver.
978
+ def attach_physics_box(size=nil); end
979
+
980
+ # Applies a continuous force to the sprite body.
981
+ # @param force [Point] the force to apply.
982
+ # @return [Sprite] the receiver.
983
+ def apply_impulse(force); end
984
+
985
+ # Applies an immediate force to the sprite body.
986
+ # @param force [Point] the force to apply.
987
+ # @return [Sprite] the receiver.
988
+ def apply_force(force); end
989
+
990
+
991
+ # @group Properties
992
+
993
+ # @return [Float] the body mass of the sprite.
994
+ attr_accessor :mass
995
+
996
+ # @return [Boolean] whether the sprite should be affected by the scene's
997
+ # gravitational force. The default is +true+.
998
+ attr_accessor :gravitates?
999
+
1000
+ # @return [Boolean] whether the sprite body should be dynamic or not in the
1001
+ # physics world. The default is +true+, and a dynamic body will affect
1002
+ # with gravity.
1003
+ attr_accessor :dynamic?
1004
+
1005
+ # @return [Float] the linear damping / air friction force on the sprite body.
1006
+ attr_accessor :friction
1007
+
1008
+ # @return [Point] the velocity force on the sprite body.
1009
+ attr_accessor :velocity
1010
+
1011
+ # @return [Boolean] whether the body is at rest.
1012
+ attr_accessor :resting?
1013
+
1014
+ # @return [Float] the moment of inertia of the body.
1015
+ attr_accessor :inertia_moment
1016
+
1017
+ # @return [Integer] physics category mask.
1018
+ attr_accessor :category_mask
1019
+
1020
+ # @return [Integer] physics contact test mask.
1021
+ attr_accessor :contact_mask
1022
+
1023
+ # @return [Integer] physics collision mask.
1024
+ attr_accessor :collision_mask
1025
+
1026
+ end
1027
+ # A point represents a location in a two-dimensional coordinate system using
1028
+ # +x+ and +y+ variables.
1029
+ # When calling a method that expects a +Point+ object, a 2-element +Array+
1030
+ # can be passed instead, as a convenience shortcut. For example,
1031
+ # node.location = [10, 20]
1032
+ # is the same as
1033
+ # point = MG::Point.new
1034
+ # point.x = 10
1035
+ # point.y = 20
1036
+ # node.location = point
1037
+ class Point < Object
1038
+
1039
+ # @group Properties
1040
+
1041
+ # @return [Float] the x coordinate of the point.
1042
+ attr_accessor :x
1043
+
1044
+ # @return [Float] the y coordinate of the point.
1045
+ attr_accessor :y
1046
+
1047
+
1048
+ # @group Helpers
1049
+
1050
+ # Adds the coordinates of the receiver with the coordinates of the given
1051
+ # point object.
1052
+ # @param point [Point]
1053
+ # @return [Point] A new Point object.
1054
+ def +(point); end
1055
+
1056
+ # Substracts the coordinates of the receiver with the coordinates of the given
1057
+ # point object.
1058
+ # @param point [Point]
1059
+ # @return [Point] A new Point object.
1060
+ def -(point); end
1061
+
1062
+ end
1063
+ # A size represents the dimensions of width and height of an object.
1064
+ # When calling a method that expects a +Size+ object, a 2-element +Array+
1065
+ # can be passed instead, as a convenience shortcut. For example,
1066
+ # node.size = [200, 400]
1067
+ # is the same as
1068
+ # size = MG::Size.new
1069
+ # size.x = 200
1070
+ # size.y = 400
1071
+ # node.size = size
1072
+ class Size < Object
1073
+
1074
+ # @group Properties
1075
+
1076
+ # @return [Float] the size width.
1077
+ attr_accessor :width
1078
+
1079
+ # @return [Float] the size height.
1080
+ attr_accessor :height
1081
+
1082
+
1083
+ # @group Helpers
1084
+
1085
+ # Adds the dimensions of the receiver with the dimensions of the given
1086
+ # size object.
1087
+ # @param size [Size]
1088
+ # @return [Size] a new Size object.
1089
+ def +(size); end
1090
+
1091
+ # Substracts the dimensions of the receiver with the dimensions of the given
1092
+ # size object.
1093
+ # @param size [Size]
1094
+ # @return [Size] a new Size object.
1095
+ def -(size); end
1096
+
1097
+ # Divides the dimensions of the receiver with the given number.
1098
+ # @param delta [Float] the number to divide the receiver with.
1099
+ # @return [Size] a new Size object.
1100
+ def /(delta); end
1101
+
1102
+ # Multiplies the dimensions of the receiver with the given number.
1103
+ # @param delta [Float] the number to multiply the receiver with.
1104
+ # @return [Size] a new Size object.
1105
+ def *(delta); end
1106
+
1107
+ end
1108
+ # A color represents the color, and sometimes opacity (alpha) of an object.
1109
+ # When calling a method that expects a +Color+ object, a 3-element +Array+
1110
+ # (red-green-blue) or 4-element +Array+ (red-green-blue-alpha) can be passed
1111
+ # instead, as a convenience shortcut. For example,
1112
+ # node.color = [0.2, 0.3, 0.4]
1113
+ # is the same as
1114
+ # color = MG::Color.new
1115
+ # color.red = 0.2
1116
+ # color.green = 0.3
1117
+ # color.blue = 0.4
1118
+ # node.color = color
1119
+ # Alternatively, a +Symbol+ corresponding to a basic color name can be
1120
+ # provided. For example,
1121
+ # node.color = :red
1122
+ # is the same as
1123
+ # color = MG::Color.new
1124
+ # color.red = 1.0
1125
+ # color.green = color.blue = 0
1126
+ # node.color = color
1127
+ # Currently, the following symbols are supported: +:white+, +:black+, +:red+,
1128
+ # +:green+ and +:blue+.
1129
+ # The +MG::Color.new+ constructor will return the black color.
1130
+ class Color < Object
1131
+
1132
+ # @group Properties
1133
+
1134
+ # @return [Float] the red portion of the color, from +0.0+ to +1.0+.
1135
+ attr_accessor :red
1136
+
1137
+ # @return [Float] the green portion of the color, from +0.0+ to +1.0+.
1138
+ attr_accessor :green
1139
+
1140
+ # @return [Float] the blue portion of the color, from +0.0+ to +1.0+.
1141
+ attr_accessor :blue
1142
+
1143
+ # @return [Float] the alpha portion of the color, from +0.0+ to +1.0+.
1144
+ attr_accessor :alpha
1145
+
1146
+ end
1147
+ # The base class for all UI widgets. You should not instantiate this class
1148
+ # directly but use a subclass instead.
1149
+ class Widget < Node
1150
+
1151
+ # @group Properties
1152
+
1153
+ # Whether the widget is enabled. When enabled, a widget can be
1154
+ # touched or clicked. By default, a widget is enabled.
1155
+ # @return [Boolean] whether the widget is enabled.
1156
+ attr_accessor :enabled?
1157
+
1158
+ # Whether the widget is touch enabled. When touch enabled, a widget supports
1159
+ # on_touch. By default, a widget is not touch enabled.
1160
+ # @return [Boolean] whether the widget is touch enabled.
1161
+ attr_accessor :touch_enabled?
1162
+
1163
+ # Whether the widget is highlighted. By default, a widget is not highlighted.
1164
+ # @return [Boolean] whether the widget is highlighted.
1165
+ attr_accessor :highlighted?
1166
+
1167
+
1168
+ # @group Events
1169
+
1170
+ # Configures a block to be called when a touch event is received on the
1171
+ # widget.
1172
+ # @yield [Symbol] the given block will be called when the event
1173
+ # is received with a +Symbol+ that describes the type of event, which can
1174
+ # be +:begin+, +:move+, +:end+ or +:cancel+.
1175
+ # @return [Widget] the receiver.
1176
+ def on_touch; end
1177
+
1178
+ end
1179
+
1180
+ class Text < Widget
1181
+
1182
+ # @group Constructors
1183
+
1184
+ # Creates a new Text widget with optional content, font name and size.
1185
+ # @param text [String] content for the text widget.
1186
+ # @param font [String] name of the font the text widget should use.
1187
+ # @param font_size [Integer] size of the font the text widget should use.
1188
+ def initialize(text='', font='', font_size=0); end
1189
+
1190
+
1191
+ # @group Properties
1192
+
1193
+ # @return [String] content of the widget.
1194
+ attr_accessor :text
1195
+
1196
+ # @return [Color] color of the text part of the widget.
1197
+ attr_accessor :text_color
1198
+
1199
+ # @return [String] name of the font used by the widget.
1200
+ attr_accessor :font
1201
+
1202
+ # @return [Integer] size of the font used by the widget.
1203
+ attr_accessor :font_size
1204
+
1205
+ # @return [Size] the text rendering area size.
1206
+ attr_accessor :area_size
1207
+
1208
+ # @return [:top, :center, :bottom] the vertical alignment of the text.
1209
+ attr_accessor :vertical_align
1210
+
1211
+ # @return [:left, :center, :right] the horizontal alignment of the text.
1212
+ attr_accessor :horizontal_align
1213
+
1214
+ end
1215
+ # A button widget. The {#on_touch} method can be used to set a callback when
1216
+ # the button is activated. Example:
1217
+ # button = Button.new("Touch me!")
1218
+ # button.on_touch { |type| puts "touched!" if type == :end }
1219
+ class Button < Widget
1220
+
1221
+ # @group Constructors
1222
+
1223
+ # Creates a new Button widget with an optional title.
1224
+ # @param title [String] title for the button.
1225
+ def initialize(title=''); end
1226
+
1227
+
1228
+ # @group Properties
1229
+
1230
+ # @return [String] title of the button.
1231
+ attr_accessor :text
1232
+
1233
+ # @return [Color] color of the title.
1234
+ attr_accessor :text_color
1235
+
1236
+ # @return [String] name of the font used for the button title.
1237
+ attr_accessor :font
1238
+
1239
+ # @return [Integer] size of the font used by for button title.
1240
+ attr_accessor :font_size
1241
+
1242
+ # @return [Float] the value with which the button will zoom when the user
1243
+ # presses it.
1244
+ attr_accessor :zoom_scale
1245
+
1246
+ end
1247
+
1248
+ class Slider < Widget
1249
+
1250
+ # @group Constructors
1251
+
1252
+ # Creates a new Slider widget.
1253
+ def initialize; end
1254
+
1255
+
1256
+ # @group Properties
1257
+
1258
+ # @return [Integer] the progress direction of the slider, as a percentage
1259
+ # value from +1+ to +100+.
1260
+ attr_accessor :progress
1261
+
1262
+ end
1263
+
1264
+ class Layout < Widget
1265
+
1266
+ # @group Constructors
1267
+
1268
+ # Creates a new List widget.
1269
+ def initialize; end
1270
+
1271
+
1272
+ # @group Properties
1273
+
1274
+ # @return [:absolute, :vertical, :horizontal, :relative] the layout type.
1275
+ attr_accessor :type
1276
+
1277
+ # @return [Color] the background color of the widget.
1278
+ attr_accessor :background_color
1279
+
1280
+ # @return [Boolean] whether the layout can clip its content and children
1281
+ # (default is false).
1282
+ attr_accessor :clipping?
1283
+
1284
+ end
1285
+
1286
+ class Scroll < Layout
1287
+
1288
+ # @group Constructors
1289
+
1290
+ # Creates a new Scroll widget.
1291
+ def initialize; end
1292
+
1293
+
1294
+ # @group Properties
1295
+
1296
+ # @return [:none, :vertical, :horizontal, :both] the direction of the scroll
1297
+ # view.
1298
+ attr_accessor :direction
1299
+
1300
+ # @return [Size] the inner container size of the scroll view, which must be
1301
+ # larger or equal than the size of the scroll view itself.
1302
+ attr_accessor :inner_size
1303
+
1304
+ # @return [Layout] the inner container of the scroll view.
1305
+ attr_reader :inner_container
1306
+
1307
+ end
1308
+
1309
+ class List < Scroll
1310
+
1311
+ # @group Constructors
1312
+
1313
+ # Creates a new List widget.
1314
+ def initialize; end
1315
+
1316
+
1317
+ # @group Managing Items
1318
+
1319
+ # Adds a new item to the end of the list.
1320
+ # @param widget [Widget] the item to add.
1321
+ # @return [List] the receiver.
1322
+ def add_item(widget); end
1323
+
1324
+ # Inserts a new item at the given index in the list.
1325
+ # @param index [Integer] the index where to add the item.
1326
+ # @param widget [Widget] the item to add.
1327
+ # @return [List] the receiver.
1328
+ def insert_item(index, widget); end
1329
+
1330
+ # Retrieves the item at the given index.
1331
+ # @param index [Integer] the index to look up.
1332
+ # @return [Widget] the item at the given index, or +nil+ if there isn't any.
1333
+ def item_at(index); end
1334
+
1335
+ # Deletes the item at the given index.
1336
+ # @param index [Integer] the index to look up.
1337
+ # @return [List] the receiver.
1338
+ def delete_item(index); end
1339
+
1340
+ # Removes all items in the list.
1341
+ # @return [List] the receiver.
1342
+ def clear_items; end
1343
+
1344
+
1345
+ # @group Selection
1346
+
1347
+ # Configures a block to be called when an item is selected in the list view.
1348
+ # @yield [Integer] the given block will be called when an item is selected,
1349
+ # passing the index of the selection as the argument.
1350
+ # @return [List] the receiver.
1351
+ def on_selection; end
1352
+
1353
+ # @return [Integer] the index of the currently selected item.
1354
+ def selected_item; end
1355
+
1356
+
1357
+ # @group Properties
1358
+
1359
+ # @return [Float] the margin between items in the list.
1360
+ attr_accessor :items_margin
1361
+
1362
+ end
1363
+
1364
+ class Web < Widget
1365
+
1366
+ # @group Constructors
1367
+
1368
+ # Creates a new Web widget.
1369
+ def initialize; end
1370
+
1371
+
1372
+ # @group Loading Data
1373
+
1374
+ # Loads a given HTML data into the widget.
1375
+ # @param str [String] the HTML string to load.
1376
+ # @param baseurl [String] the base URL for the content.
1377
+ # @return [Web] the receiver.
1378
+ def load_html(str, baseurl); end
1379
+
1380
+ # Loads a given URL into the widget.
1381
+ # @param url [String] the URL to load.
1382
+ # @return [Web] the receiver.
1383
+ def load_url(url); end
1384
+
1385
+ # Loads a given file into the widget.
1386
+ # @param path [String] the file to load.
1387
+ # @return [Web] the receiver.
1388
+ def load_file(path); end
1389
+
1390
+ # Stops the current loading.
1391
+ # @return [Web] the receiver.
1392
+ def stop; end
1393
+
1394
+ # Reloads the current context.
1395
+ # @return [Web] the receiver.
1396
+ def reload; end
1397
+
1398
+
1399
+ # @group JavaScript Interface
1400
+
1401
+ # Evaluates the given JavaScript expression.
1402
+ # @param expr [String] a JavaScript expression to evaluate.
1403
+ # @return [Web] the receiver.
1404
+ def evaluate(expr); end
1405
+
1406
+ end
1407
+ end