toto88x Posted December 29, 2013 Share Posted December 29, 2013 Hello, I almost finished my first Phaser game! Below are my questions. 1) How can I change the volume of one sound in my game? And what about all sounds? Something like- var hit = game.add.audio('hit');- hit.volume = 0.5; 2) How can I change the font size of a text? Because changing fontSize: '32px' doesn't seems to work.- game.add.text(w/2, h-35, 'this is a test', { fontSize: '18px', fill: '#fff', align: 'center' }); 3) When I do a game.state.start('GameOver'), should I clean all my variables to free memory? If so, is there a function automatically called before switching states? 4) I know about tween().to(), but isn't there something like tween().by()? This would be super handy to move a character by 100px, instead of moving him to character.x + 100px. Thanks! :-) Link to comment Share on other sites More sharing options...
XekeDeath Posted December 29, 2013 Share Posted December 29, 2013 1) I haven't messed with volume on sounds yet, but both the Phaser.Sound and Phaser.SoundManager classes have a volume property. 2) See here for the available font properties:http://www.goodboydigital.com/pixijs/docs/classes/Text.htmlThere is no fontSize property, you include that in the font property. eg: 18px Arial 3) Probably a good idea. A state object has it's create function called when switching to it, and if an existing state was there, the existing state has its shutdown function called. 4) Nope. jerome 1 Link to comment Share on other sites More sharing options...
toto88x Posted December 29, 2013 Author Share Posted December 29, 2013 Thanks a lot! A few comments: 1) Yes I've seen that, but I don't know how to make it work :-/ 2) Perfect, it works! But it seems the fonts are somewhat blurry. Is this normal? What I'm doing: game.add.text(w/2, h/2, 'blurry text', { font: "18px Arial", fill: '#fff' }); 3) shutdown works perfectly! 4) Ok, maybe in v1.2 then ^^ Link to comment Share on other sites More sharing options...
XekeDeath Posted December 29, 2013 Share Posted December 29, 2013 The problem there is probably positioning... Try rounding the x/y values. I usually use Math.floor:game.add.text(Math.floor(w/2), Math.floor(h/2), 'blurry text', { font: "18px Arial", fill: '#fff' }); Link to comment Share on other sites More sharing options...
rich Posted December 30, 2013 Share Posted December 30, 2013 4) I know about tween().to(), but isn't there something like tween().by()? This would be super handy to move a character by 100px, instead of moving him to character.x + 100px. You can do this:tween(sprite).to( { x: '+100' });It will recognise +100 is a string and add 100px to the sprites current x position when the tween starts. Minus values work the same too. Link to comment Share on other sites More sharing options...
toto88x Posted December 30, 2013 Author Share Posted December 30, 2013 You can do this:tween(sprite).to( { x: '+100' });It will recognise +100 is a string and add 100px to the sprites current x position when the tween starts. Minus values work the same too. Super nice, thanks! I still don't know how to change the volume of sounds in the game (either a specific sound, or for all of them). Can anyone help me on this? Link to comment Share on other sites More sharing options...
rich Posted December 30, 2013 Share Posted December 30, 2013 Set the volume property on the sound? It's between 0 and 1 and you usually set it on the call to play the sound. Link to comment Share on other sites More sharing options...
BunBunBun Posted January 8, 2014 Share Posted January 8, 2014 Hi all, I have also some questions about Phaser, dunno need to create a new topic for that or no, but will ask here: 1) first two parameters don't work in tilemapLayer functionx - X position of the new tilemapLayer.y - Y position of the new tilemapLayer.layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); I use that example:http://www.gametest.mobi/phaser/examples/sideview.html write:layer = game.add.tilemapLayer(50, 50, 800, 600, tileset, map, 0); and I don't see any changes. I just want to move the tilemapLayer to x = 50; y = 50. alsolayer.x = 50;layer.y = 50;don't work for me let me know please what need to do. 2) Rich said, "In 1.1.4 I've added the ability to render multiple layers to a single canvas, but that won't be ready until end of this month."does anyone know is this available or not now? I mean of course dev-branch version of Phaser. Link to comment Share on other sites More sharing options...
rich Posted January 8, 2014 Share Posted January 8, 2014 I've been working on both of these things today actually. Keep an eye on the commit messages on the dev branch, it will be obvious when they're ready to test. Link to comment Share on other sites More sharing options...
BunBunBun Posted January 9, 2014 Share Posted January 9, 2014 Thanks rich, I look forward to it! Link to comment Share on other sites More sharing options...
BunBunBun Posted January 13, 2014 Share Posted January 13, 2014 about the 1st of my item - I found a temporary solution via group. if you want to move your tilemapLayer - you can just place him into the group and move it.var screen = game.add.group();layer = screen.add(game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0));screen.x = 50;screen.y = 50; Link to comment Share on other sites More sharing options...
Recommended Posts