phaserjs / phaser-ce-examples

Contains hundreds of source code examples and related media for the Phaser HTML5 Game Framework.

Home Page:http://phaser.io/examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help needed with gemmatch example

ugajin-nijagu opened this issue · comments

I have been looking at: http://phaser.io/examples/v2/games/gemmatch example.

It appears that the columns and rows array defaults to the game origin, which can cause the sprites to appear off centre, when e.g. GEM_SPACING is set to a positive value, and seen relative to the canvas/game border.

I added a couple of lines of code which will [visually] centre the 'gems' to the game. The code lets you adjust the GEM_SPACING and/or canvas/game dimension values, and updates the 'gem' anchor value[s] accordingly.

Also, as part of the exercise, I put the whole code into an 'iife' container to protect the otherwise exposed code.

However, what I can't seem to do, is to create a margin between the canvas edges and the 'gem' array [group] without breaking the code.

I introduced a ‘placeholder sprite and built the gem array using the placholder dimensions, which lets me create an array based on smaller than game world dimensions, But again it defaults to the top left of the game world.

Setting a ‘gems.x’ value, and/or by further tweaking the gem.anchor values makes a mess, and I have tried tracing the 'gem' pipeline with very limited success. I can get the GEMS to fly in from an adjusted position, but that's about it.

I tried posting on the board and got a nil response.

Any help and suggestions, are welcome.

Thank you for considering this.

-u