Skip to content

Commit dbe5cfb

Browse files
committed
Added example player image and block for Phaser implementation.
Updated Phaser CE to latest version.
1 parent e1dd428 commit dbe5cfb

File tree

10 files changed

+366
-147
lines changed

10 files changed

+366
-147
lines changed

package-lock.json

Lines changed: 250 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dependencies": {},
99
"devDependencies": {
1010
"bestzip": "^1.1.6",
11-
"closure-builder": "^2.3.4",
11+
"closure-builder": "^2.3.6",
1212
"command-line-usage": "^5.0.5",
1313
"escape-string-regexp": "^1.0.5",
1414
"eslint": "^4.19.1",
@@ -26,9 +26,9 @@
2626
"markdownlint": "^0.8.1",
2727
"markdownlint-cli": "^0.8.1",
2828
"mv": "^2.1.1",
29-
"nw": "^0.31.5",
29+
"nw": "^0.37.0",
3030
"nw-builder": "^3.5.7",
31-
"replace-in-file": "^3.4.3",
31+
"replace-in-file": "^3.4.4",
3232
"rimraf": "^2.6.3"
3333
},
3434
"scripts": {

src/blocks/general/sample/blocks.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,23 @@ Blockly.Blocks['general_sample_image_paddle'] = {
138138
};
139139

140140

141+
/**
142+
* Sample image: player.png
143+
*/
144+
Blockly.Blocks['general_sample_image_player'] = {
145+
init: function() {
146+
this.appendDummyInput()
147+
.appendField(new Blockly.FieldImage('../images/samples/player.png',
148+
42, 42, ''));
149+
this.setInputsInline(false);
150+
this.setOutput(true, 'Image');
151+
this.setColour(150);
152+
this.setTooltip('');
153+
this.setHelpUrl('');
154+
},
155+
};
156+
157+
141158
/**
142159
* Sample image: bg/bg_01.png
143160
*/

src/blocks/general/sample/javascript.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,37 @@ Blockly.JavaScript['general_sample_image_paddle'] = function() {
173173
};
174174

175175

176+
/**
177+
* Sample image: player.png
178+
* @return {string}
179+
*/
180+
Blockly.JavaScript['general_sample_image_player'] = function() {
181+
let image = 'data:image/png;base64,' +
182+
'iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAMAAADyHTlpAAAB9VBMVEUAAAD///8gcrsCi/DQ' +
183+
'0NDBwsECjO79/f37/PseuZ0AAADx8vLp7PHNy8tdyk0EkuVekL0lccC343aG0RzZ2dkgnqeQ' +
184+
'l5kdccMRsrJrbm8Bhvfn5uYJntMswoTw8PAXuaQrgY00h2plnC/6+vv39/fs7Ozd3d3U1NQd' +
185+
'dMskbbS04nB2vSAmk/wDj+rh4eHg4ODb29vS0tLFxcS/y7ckeq0pv4YrhHwrhniIqltMx1oT' +
186+
'i/wBifMIhO3o6ezo6OjW1tYOmNDOzc3LysrFxcXExcQgb70OrbshdrYnbK4ubanO6aU2bqId' +
187+
'uZ1AcJ0qfpUqhYa64IIqhn4rjndDxWY/omBJx15dyUxayUtSqEiQ1DRlpTBmky8ej/ru7+0q' +
188+
'iuPi4uITfOIFleHm7twHmNqcuNEKo8tqm8gXj8cahMQMqMPT4b8edb9ej7vW7bTK3LOwsLAc' +
189+
'n6+zwacXsaYme6YhmqRqiaTI5J4YvZ5LeJ6OmJ0pfZ0cpZtggJkevpfE45apu5U4apUcq5LA' +
190+
'4o0kwIwueYkjmIUkloWetIK02no1xHkvinI7xHGTrm8yk26OqG2v3Ws3nGo2lmpMtFRKpFJL' +
191+
'olFXyU+f101/pUhhyked2UVszEJewkJ4zz9bqj5zmT6D0TyW1jthqjaBtTVxnDSH0CZupCWA' +
192+
'yR8Im87rAAAAAXRSTlMAQObYZgAAAhxJREFUOMu11NVf21AUwPGbpjSBtnQjWYRQS92Nlpbh' +
193+
'MGDAcBkwd3d3d3f37e/cTUJGkt0+tfxeznn4PtzPebhg5WvELfrwxnKyiXOP1C434ua62pCy' +
194+
'NeHOl+Zm69Vm50r5i/vCKBpPnJ2h3kcb1KJv/ry40xwBqCzumfkhElMjj/zY2NK8Hklxburb' +
195+
'YUKVhC/35WVhYBhJ1/Y/nB/y1dXZJAnH8cXpiYMb0HT//a9n/Mv06uL0GFvmWLudn65YFUrA' +
196+
'cVd85llX7q7ODzc09NHC49EytHXnzXfjLoVK7yh+f3AhAtBtv/x6fLPNRhIYYYO9/dxyclAv' +
197+
'TPjS4nCXnu5w8X6StLbz7bmf/86Km4w0wU39uneA4QVB4Jnck9+vJgaGjTSuLJb+/MdYrMjw' +
198+
'PM8UY7GF52Mm+axxhUZwmMOhnKDrxPVJr7fAMEzB6/VO3r7FnpMfJpkIMMFUu6lt77E1MI7j' +
199+
'pHFqdJC9pEhJASkJy3bLtvBqTeHwtfOyVJzO7tqzStuh00xWlUYbtNfo6qNVabTBYMCqLZCi' +
200+
'VWm0tEAS2sgAnVGl3qaCLgLTRviTdoSElk76MH2EEDKj6Fa6gyB9pC5XugdF02mX0G3X1tMZ' +
201+
'SGVCCNoZMv9XdybUh6C0GVXvUQTtsNcg6qVBZbGsRakJtrSyLKg0j6dWzgmTF48HVCNRrIdR' +
202+
'MDhEEVQtioK/cLSBokB1S2LZLAYq6S82IV4PAnrfgAAAAABJRU5ErkJggg==';
203+
return [image, Blockly.JavaScript.ORDER_NONE];
204+
};
205+
206+
176207
/**
177208
* Sample image: bg/bg_01.png
178209
* @return {string}

src/blocks/phaser/arcade_physics/blocks.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Blockly.Blocks['phaser_physics_arcade_sprite_adjust'] = {
200200

201201

202202
/**
203-
* Adjust arcade sprite.
203+
* Adjust arcade sprite (custom).
204204
*/
205205
Blockly.Blocks['phaser_physics_arcade_sprite_adjust_custom'] = {
206206
init: function() {
@@ -272,6 +272,29 @@ Blockly.Blocks['phaser_physics_arcade_sprite_adjust_dimension'] = {
272272
};
273273

274274

275+
/**
276+
* Adjust arcade sprite dimension (custom).
277+
*/
278+
Blockly.Blocks['phaser_physics_arcade_sprite_adjust_dimension_custom'] = {
279+
init: function() {
280+
this.appendDummyInput()
281+
.appendField(i18t('@@BLOCKS__SET'))
282+
.appendField(i18t('dimension to'));
283+
this.appendValueInput('width')
284+
.setCheck('Number');
285+
this.appendValueInput('height')
286+
.appendField('x')
287+
.setCheck('Number');
288+
this.setPreviousStatement(true, ['PhysicsArcadeAttribute']);
289+
this.setNextStatement(true, ['PhysicsArcadeAttribute']);
290+
this.setInputsInline(true);
291+
this.setColour(0);
292+
this.setTooltip('');
293+
this.setHelpUrl('');
294+
},
295+
};
296+
297+
275298
/**
276299
* Destroys arcade sprite.
277300
*/

src/blocks/phaser/arcade_physics/javascript.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Blockly.JavaScript['phaser_physics_arcade_sprite_adjust'] = function(block,
154154

155155

156156
/**
157-
* Adjust arcade sprite.
157+
* Adjust arcade sprite custom.
158158
* @param {Blockly.Block} block
159159
* @return {string}
160160
*/
@@ -168,12 +168,13 @@ Blockly.JavaScript['phaser_physics_arcade_sprite_adjust_custom'] = function(
168168
/**
169169
* Adjust arcade sprite dimension.
170170
* @param {Blockly.Block} block
171+
* @param {string=} variableName
171172
* @return {string}
172173
*/
173174
Blockly.JavaScript['phaser_physics_arcade_sprite_adjust_dimension'] = function(
174-
block) {
175+
block, variableName = '') {
175176
let variable = Blockly.JavaScript.valueToCode(block,
176-
'variable', Blockly.JavaScript.ORDER_ATOMIC);
177+
'variable', Blockly.JavaScript.ORDER_ATOMIC) || variableName;
177178
let value_width = Blockly.JavaScript.valueToCode(
178179
block, 'width', Blockly.JavaScript.ORDER_ATOMIC) || 50;
179180
let value_height = Blockly.JavaScript.valueToCode(
@@ -183,6 +184,18 @@ Blockly.JavaScript['phaser_physics_arcade_sprite_adjust_dimension'] = function(
183184
};
184185

185186

187+
/**
188+
* Adjust arcade sprite dimension custom.
189+
* @param {Blockly.Block} block
190+
* @return {string}
191+
*/
192+
Blockly.JavaScript['phaser_physics_arcade_sprite_adjust_dimension_custom'] =
193+
function(block) {
194+
return Blockly.JavaScript['phaser_physics_arcade_sprite_adjust_dimension'](
195+
block, 'arcadeSpriteCustom');
196+
};
197+
198+
186199
/**
187200
* Destroys arcade sprite.
188201
* @param {Blockly.Block} block

src/blocks/phaser/toolbox.soy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@
206206
</value>
207207
</block>
208208

209+
<block type="phaser_load_image">
210+
<field name="name">player</field>
211+
<value name="image">
212+
<block type="general_sample_image_player"></block>
213+
</value>
214+
</block>
215+
209216
<block type="phaser_load_image">
210217
<field name="name">bg_01</field>
211218
<value name="image">

src/blocks/phaser/toolbox_arcade_physics.soy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@
224224
<value name="y">
225225
<block type="math_number"><field name="NUM">200</field></block>
226226
</value>
227+
<statement name="CODE">
228+
<block type="phaser_physics_arcade_sprite_adjust_custom">
229+
<value name="value">
230+
<block type="math_number"></block>
231+
</value>
232+
</block>
233+
</statement>
227234
</block>
228235

229236
<block type="phaser_physics_arcade_sprite_paddle_add">
@@ -263,6 +270,16 @@
263270
<block type="math_number"></block>
264271
</value>
265272
</block>
273+
274+
275+
<block type="phaser_physics_arcade_sprite_adjust_dimension_custom">
276+
<value name="width">
277+
<block type="math_number"><field name="NUM">50</field></block>
278+
</value>
279+
<value name="height">
280+
<block type="math_number"><field name="NUM">50</field></block>
281+
</value>
282+
</block>
266283
{/template}
267284

268285

1.1 KB
Loading

third_party/phaser-ce

0 commit comments

Comments
 (0)