Skip to content

Commit 8bfc924

Browse files
committed
Miscellaneous fixes
1. Fixed issue with ErrorEvent - message was missing 2. Added missing API methods to various Phaser classes
1 parent 3b19308 commit 8bfc924

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1702
-152
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ The following applications were developed using ScalaJs.io:
7575

7676
| Application | Frontend | Backend | Scalajs.io version | Description |
7777
|------------------------------------------------------------------------|-----------------------|--------------------|--------------------|------------------------------------------|
78-
| [Scalajs-Invaders](https://github.com/ldaniels528/scalajs-invaders) | Scala.js + DOM | Scala + NodeJS | 0.3.0.0 | Port of Phaser Invaders. |
79-
| [Socialize](https://github.com/ldaniels528/scalajs-nodejs-socialized) | Scala.js + AngularJS | Scala.js + NodeJS | 0.2.3.1 | A Facebook-inspired Social networking web application. |
78+
| [Scalajs-Invaders](https://github.com/ldaniels528/scalajs-invaders) | Scala.js + DOM | Scala + NodeJS | 0.3.0.1 | Port of Phaser Invaders. |
79+
| [Socialize](https://github.com/ldaniels528/scalajs-nodejs-socialized) | Scala.js + AngularJS | Scala.js + NodeJS | 0.3.0.3 | A Facebook-inspired Social networking web application. |
8080
| [Todo MVC](https://github.com/ldaniels528/scalajs-nodejs-todomvc) | Scala.js + AngularJS | Scala.js + NodeJS | 0.2.3.1 | A simple Todo example application. |
8181
| [Trifecta](https://github.com/ldaniels528/trifecta) | Scala.js + AngularJS | Scala + Play 2.4.x | 0.3.0.0 | Trifecta is a web-based and CLI tool that simplifies inspecting Kafka messages and Zookeeper data. |
8282

browser/dom/src/main/scala/io/scalajs/dom/ws/ErrorEvent.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ import scala.scalajs.js
99
* being a WebSocket or a WebRTC RTCDataChannel.
1010
*/
1111
@js.native
12-
class ErrorEvent() extends Event {}
12+
class ErrorEvent() extends Event {
13+
14+
def message: String = js.native
15+
16+
}

browser/phaser/src/main/scala/io/scalajs/dom/html/phaser/ArcadePhysics.scala

Lines changed: 0 additions & 30 deletions
This file was deleted.

browser/phaser/src/main/scala/io/scalajs/dom/html/phaser/AudioSprite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scala.scalajs.js.annotation.JSName
1111
*/
1212
@js.native
1313
@JSName("Phaser.AudioSprite")
14-
class AudioSprite(val game: Game, val key: String) extends js.Object {
14+
class AudioSprite(var game: Phaser.Game, var key: String) extends js.Object {
1515

1616
/////////////////////////////////////////////////////////////////////////////////
1717
// Properties

browser/phaser/src/main/scala/io/scalajs/dom/html/phaser/BitmapText.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import scala.scalajs.js.annotation.JSName
2929
*/
3030
@js.native
3131
@JSName("Phaser.BitmapText")
32-
class BitmapText(val game: Game,
32+
class BitmapText(var game: Phaser.Game,
3333
override var x: Double,
3434
override var y: Double,
3535
val font: String,
@@ -62,4 +62,14 @@ class BitmapText(val game: Game,
6262
*/
6363
override var angle: Double = js.native
6464

65+
/**
66+
* Base destroy method for generic display objects.
67+
*/
68+
override def destroy(): Unit = js.native
69+
70+
/**
71+
* Base destroy method for generic display objects.
72+
*/
73+
override def destroy(destroyChildren: Boolean): Unit = js.native
74+
6575
}

browser/phaser/src/main/scala/io/scalajs/dom/html/phaser/Cache.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import scala.scalajs.js.annotation.JSName
3030
*/
3131
@js.native
3232
@JSName("Phaser.Cache")
33-
class Cache(val game: Game) extends js.Object {}
33+
class Cache(var game: Phaser.Game) extends js.Object {}
3434

3535
@js.native
3636
@JSName("Phaser.Cache")

browser/phaser/src/main/scala/io/scalajs/dom/html/phaser/Camera.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import scala.scalajs.js.annotation.JSName
1515
*/
1616
@js.native
1717
@JSName("Phaser.Camera")
18-
class Camera(val game: Game, val id: Int = 0, var x: Double, var y: Double, var width: Double, var height: Double)
18+
class Camera(var game: Phaser.Game, val id: Int = 0, var x: Double, var y: Double, var width: Double, var height: Double)
1919
extends js.Object {
2020

2121
/**

browser/phaser/src/main/scala/io/scalajs/dom/html/phaser/GameObjectCreator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import scala.scalajs.js.annotation.JSName
1313
*/
1414
@js.native
1515
@JSName("Phaser.GameObjectCreator")
16-
class GameObjectCreator(val game: Game) extends js.Object {
16+
class GameObjectCreator(var game: Phaser.Game) extends js.Object {
1717

1818
/////////////////////////////////////////////////////////////////////////////////
1919
// Properties
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
package io.scalajs.dom.html.phaser
2+
3+
import io.scalajs.RawOptions
4+
5+
import scala.scalajs.js
6+
import scala.scalajs.js.annotation.{JSName, ScalaJSDefined}
7+
8+
/**
9+
* The Gamepad class handles gamepad input and dispatches gamepad events.
10+
*
11+
* Remember to call gamepad.start().
12+
*
13+
* HTML5 GAMEPAD API SUPPORT IS AT AN EXPERIMENTAL STAGE!
14+
* At moment of writing this (end of 2013) only Chrome supports parts of it out of the box. Firefox supports it
15+
* via prefs flags (about:config, search gamepad). The browsers map the same controllers differently.
16+
* This class has constants for Windows 7 Chrome mapping of XBOX 360 controller.
17+
* @see http://phaser.io/docs/2.6.2/Phaser.Gamepad.html
18+
*/
19+
@js.native
20+
@JSName("Phaser.Gamepad")
21+
class Gamepad(var game: Phaser.Game) extends js.Object {
22+
23+
/////////////////////////////////////////////////////////////////////////////////
24+
// Properties
25+
/////////////////////////////////////////////////////////////////////////////////
26+
27+
/**
28+
* If the gamepad input is active or not - if not active it should not be updated from Input.js
29+
*/
30+
def active: Boolean = js.native
31+
32+
/**
33+
* The context under which the callbacks are run.
34+
*/
35+
var callbackContext: js.Object = js.native
36+
37+
/**
38+
* Gamepad input will only be processed if enabled (default: true).
39+
*/
40+
var enabled: Boolean = js.native
41+
42+
/**
43+
* This callback is invoked every time any gamepad axis is changed.
44+
*/
45+
var onAxisCallback: js.Function = js.native
46+
47+
/**
48+
* This callback is invoked every time any gamepad is disconnected
49+
*/
50+
var onConnectCallback: js.Function = js.native
51+
52+
/**
53+
* This callback is invoked every time any gamepad button is pressed down.
54+
*/
55+
var onDownCallback: js.Function = js.native
56+
57+
/**
58+
* This callback is invoked every time any gamepad button is changed to a value where value > 0 and value < 1.
59+
*/
60+
var onFloatCallback: js.Function = js.native
61+
62+
/**
63+
* This callback is invoked every time any gamepad button is released.
64+
*/
65+
var onUpCallback: js.Function = js.native
66+
67+
/**
68+
* Gamepad #1
69+
*/
70+
def pad1: Phaser.SinglePad = js.native
71+
72+
/**
73+
* Gamepad #2
74+
*/
75+
def pad2: Phaser.SinglePad = js.native
76+
77+
/**
78+
* Gamepad #3
79+
*/
80+
def pad3: Phaser.SinglePad = js.native
81+
82+
/**
83+
* Gamepad #4
84+
*/
85+
def pad4: Phaser.SinglePad = js.native
86+
87+
/**
88+
* How many live gamepads are currently connected.
89+
*/
90+
def padsConnected: Int = js.native
91+
92+
/**
93+
* Whether or not gamepads are supported in current browser.
94+
*/
95+
def supported: Boolean = js.native
96+
97+
/////////////////////////////////////////////////////////////////////////////////
98+
// Methods
99+
/////////////////////////////////////////////////////////////////////////////////
100+
101+
/**
102+
* Add callbacks to the main Gamepad handler to handle connect/disconnect/button down/button
103+
* up/axis change/float value buttons.
104+
* @param context The context under which the callbacks are run.
105+
* @param callbacks Object that takes six different callback methods:
106+
* onConnectCallback, onDisconnectCallback, onDownCallback, onUpCallback,
107+
* onAxisCallback, onFloatCallback
108+
*/
109+
def addCallbacks(context: RawOptions, callbacks: Callbacks): Unit = js.native
110+
111+
/**
112+
* Destroys this object and the associated event listeners.
113+
*/
114+
def destroy(): Unit = js.native
115+
116+
/**
117+
* Returns true if the button is currently pressed down, on ANY gamepad.
118+
* @param buttonCode The buttonCode of the button to check for.
119+
* @return True if a button is currently down.
120+
*/
121+
def isDown(buttonCode: ButtonCode): Boolean = js.native
122+
123+
/**
124+
* Returns the "just released" state of a button from ANY gamepad connected.
125+
* Just released is considered as being true if the button was released within
126+
* the duration given (default 250ms).
127+
* @param buttonCode The buttonCode of the button to check for.
128+
* @param duration The duration below which the button is considered as being just released.
129+
* @return True if the button is just released otherwise false.
130+
*/
131+
def justPressed(buttonCode: ButtonCode, duration: Double = js.native): Boolean = js.native
132+
133+
/**
134+
* Reset all buttons/axes of all gamepads
135+
*/
136+
def reset(): Unit = js.native
137+
138+
/**
139+
* Sets the deadZone variable for all four gamepads
140+
*/
141+
def setDeadZones(): Unit = js.native
142+
143+
/**
144+
* Starts the Gamepad event handling.
145+
* This MUST be called manually before Phaser will start polling the Gamepad API.
146+
*/
147+
def start(): Unit = js.native
148+
149+
/**
150+
* Stops the Gamepad event handling.
151+
*/
152+
def stop(): Unit = js.native
153+
154+
}
155+
156+
/**
157+
* Callbacks Object
158+
* @param onConnectCallback
159+
* @param onDisconnectCallback
160+
* @param onDownCallback
161+
* @param onUpCallback
162+
* @param onAxisCallback
163+
* @param onFloatCallback
164+
*/
165+
@ScalaJSDefined
166+
class Callbacks(var onConnectCallback: js.UndefOr[js.Function] = js.undefined,
167+
var onDisconnectCallback: js.UndefOr[js.Function] = js.undefined,
168+
var onDownCallback: js.UndefOr[js.Function] = js.undefined,
169+
var onUpCallback: js.UndefOr[js.Function] = js.undefined,
170+
var onAxisCallback: js.UndefOr[js.Function] = js.undefined,
171+
var onFloatCallback: js.UndefOr[js.Function] = js.undefined) extends js.Object

browser/phaser/src/main/scala/io/scalajs/dom/html/phaser/Graphics.scala

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import scala.scalajs.js.annotation.JSName
1616
*/
1717
@js.native
1818
@JSName("Phaser.Graphics")
19-
class Graphics(val game: Phaser.Game,
19+
class Graphics(var game: Phaser.Game,
2020
override var x: Double,
2121
override var y: Double)
2222
extends pixijs.Graphics
@@ -32,6 +32,27 @@ class Graphics(val game: Phaser.Game,
3232
with Phaser.Component.PhysicsBody
3333
with Phaser.Component.Reset {
3434

35+
/**
36+
* The angle property is the rotation of the Game Object in degrees from its original orientation.
37+
*
38+
* Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
39+
*
40+
* Values outside this range are added to or subtracted from 360 to obtain a value within the range.
41+
* For example, the statement player.angle = 450 is the same as player.angle = 90.
42+
*
43+
* If you wish to work in radians instead of degrees you can use the property rotation instead.
44+
* Working in radians is slightly faster as it doesn't have to perform any calculations.
45+
*/
3546
override var angle: Double = js.native
3647

48+
/**
49+
* Base destroy method for generic display objects.
50+
*/
51+
override def destroy(): Unit = js.native
52+
53+
/**
54+
* Base destroy method for generic display objects.
55+
*/
56+
override def destroy(destroyChildren: Boolean): Unit = js.native
57+
3758
}

0 commit comments

Comments
 (0)