Search the Community
Showing results for tags 'dimension'.
Found 2 results
notalentgeek posted a topic in Phaser 2I am currently learning Phaser by doing some examples. I am currently here: https://phaser.io/examples/v2/animation/creature-dragon-multiple. I am wondering, how can I set the height and width of `Phaser.Creature` object? The default `height` and `width` are set to undefined. Hence I need to set both height and width in order to set the `Phaser.Creature` dimension. Here are some codes. dragon_character.play(true); // `true` is used for looping forever. dragon_character.scale.set(20); dragon_character.height = 100; dragon_character.width = 100; console.log(dragon_character.height); // 100. console.log(dragon_character.width); // 100. Here are another codes. dragon_character.play(true); // `true` is used for looping forever. dragon_character.scale.set(20); dragon_character.height = 100; console.log(dragon_character.height); // 100. console.log(dragon_character.width); // Undefined. // Additionally the animation does not show up in the screen. If I only set either height or width, the `Phaser.Creature` will not show up in the screen. I don't know if there is no way to set height and let the width adjusted proportionally (vice-versa). Additionally, I could not found a way to get the height and width properties if the dimension is set with `Phaser.Creature.scale.set(25)`. To sum up, my questions: Is there any way to set either height or width and let the un-set properties to adjust in proportion? How can I know the `Phaser.Creature` height and width if it is set with `Phaser.Creature.scale.set()`?
I have been looking at this: http://phaser.io/examples/v2/games/gemmatch example. The columns and rows are positioned starting at the game origin, which can cause the sprites to appear off centre, when looked at relative to the canvas/game border. I have aded a couple of lines of code which [visually] centres the 'gems'. The code lets you adjust the GEM_SPACING and/or canvas/game dimension values, and updates the 'gems' [group] [*correction, each 'gem'] anchor value accordingly. However, what I can't seem to do, is to create a margin between the canvas edges and the 'gem' [group], without breaking the code. All suggestions, welcome. Thanks.... -u Correction above in bold. I don't know why this text has strikethrough applied, or why some of the above text does too!