brentstrandy

Members
  • Content count

    20
  • Joined

  • Last visited

About brentstrandy

  • Rank
    Member

Contact Methods

  • Twitter
    brentstrandy
  1. 2x graphics bigger than expected on Retina display

    I got this working and it does NOT involve halving your textures! It requires two things to work: 1) Instantiate the size of you Phaser game window based on the pixel density of the browser: new Game(640 * window.devicePixelRatio, 480 * window.devicePixelRatio, './', document.getElementById('phaserGame')); 2) Set the scale of your game based on the pixel density of the browser: if(window.devicePixelRatio === 2) { game.scale.setUserScale(.5, .5); game.scale.scaleMode = Phaser.ScaleManager.USER_SCALE; }
  2. Phaser UnderlineText

    For some strange reason Canvas API doesn't have an underline text feature. This missing feature in Canvas means you can't underline text in Phaser. I'm not sure if anyone ever missed this feature, but fear not... now you can underline text! I've extended the Phaser.Text object by adding a simple *hack* to get underlined text. GitHub Repo -> https://github.com/brentstrandy/phaser-underline-text
  3. Text Underline [SOLVED]

    I just finished extending the Phaser.Text object to add underline functionality. You can find the code here: https://github.com/brentstrandy/phaser-underline-text/blob/master/underlineText.js Any feedback would be appreciated!
  4. Text Underline [SOLVED]

    I found a workable solution by manually drawing lines under my text. It's quite straightforward too. // Text Object containing the string to be displayed let textObject = this.game.add.text(0, 0, 'My Text', { font: '18px Verdana', fill: '#000000' }, this); // Graphics Object used to draw a line let underline = this.game.add.graphics(textObject.left, textObject.bottom - 7); // Specify the line (size, color) underline.lineStyle(2, 0xE21838); // Location to start drawing the line (x, y) underline.moveTo(0, 0); // Draw a line the width of objectText's string underline.lineTo(textObject.width, 0); TIP: If you need multi-line support you can use precalculateWordWrap to break apart your string into an array and write some fancy code to put underlines below each row of text.
  5. Text Underline [SOLVED]

    Is there a way to underline text? This seems like such a simple question, but I can't find a solution on the internets. I'd image adding a simple "underline" to the font attribute would work, but no luck. this.game.add.text(0, 0, 'test', { font: '18px Verdana', fill: '#000000', wordWrap: true, wordWrapWidth: 230 }, this); Thanks for any insight!
  6. Poor Text Clarity

    I'm using Phaser to upgrade an old flash game. Unfortunately, all of the text in my game seems to have fairly poor quality. I've attached two comparison images* and included my code below. *I understand the fonts on the two images are different this.buttonText = game.add.text(35, 0, buttonText, { 'font': '18px', 'fill': '#000000' }, this.parentGroup); Any idea why Phaser's text would appear blurry? Brent
  7. Properly Destroy a Group

    Unfortunately that is not possible in Javascript Reference: http://stackoverflow.com/questions/16924116/is-it-possible-to-set-to-null-an-instance-of-a-class-within-the-class
  8. Properly Destroy a Group

    I simply want to know the best approach for destroying a group and everything within the group. According to the documentation: destroy(destroyChildren, soft) Destroys this group. Removes all children, then removes this group from its parent and nulls references. Unfortunately, I'm still finding that my references return an object - not null or undefined For reference, here is a simplified look at the object I'm trying to destroy: class MyObject extends Phaser.Group { constructor(game) { this.game = game; // Creating Phaser sprites and adding them to group } destroyObject() { this.destroy(); } }
  9. v2.4.8 Button onInputOver

    Thanks for the quick reply! Is there anywhere I can see a list of known issues so I can look this up without having to bug you?
  10. v2.4.8 Button onInputOver

    When using v2.4.7 I was able to use onInputOver to change the button's tint. Now, in v2.4.8 the onInputOver is no longer triggered. Also, the mouse pointer no longer turns into a finger pointer on mouse over. Is anyone else experiencing these issues with the Button in v2.4.8? Example of code: ClassX = function() { ... this.button = game.add.button(100, 1000, null, actionOnClick, null, 2, 1, 0); this.button.onInputOver.add(this.mouseOver, this); }; ClassX.prototype.mouseOver = function() { this.someSprite.tint = 0x88d5ea; };
  11. Stop Audio

    Simple question: Is there a way to stop all sounds that are currently playing? I'm not looking to mute. Details: I have background music that plays on a loop and will continue to play thru Phaser state changes. I'd like to start the music in one state and end the music in another state. Without passing a reference to the audio object between states, can I do something like: game.sound.<something> to get a reference to all currently playing sounds? Or maybe just a method that says game.sound.stopAllMusic?
  12. Triggering onDestroy

    Thank you @Skeptron - I had a syntactical lapse of judgement. Your solution works great!
  13. Triggering onDestroy

    I'm having a hard time triggering onDestroy for my FreezeEffect object. I've essentially set up an object that destroys itself after a few seconds. I've tested and confirmed that "destroyObject" is being called. But sometimes the game ends, the state transitions in the middle of the FreezeEffect, and the "onDestroy" method is never called. I was under the assumption that calling state.start('newState') destroys the Phaser objects in the previous state. Is that not true? Example code: // Freeze Effect FreezeEffect = function (game) { ... constructor code ... ... create tween to fade freeze effect ... // Call function to destroy the freeze effect when the tween finishes tween.onComplete.add(this.destroyObject, this); // Slow down time game.time.slowMotion = 2.0; }; FreezeEffect.prototype = Object.create(Phaser.Group.prototype); FreezeEffect.prototype.constructor = FreezeEffect; FreezeEffect.prototype.destroyObject = function() { // Put time at normal speed this.game.time.slowMotion = 1.0; this.parentGroup.destroy(true, false); this.freezeSFX.destroy(); // Destroy the object and free memory this.destroy(true, false); }; FreezeEffect.prototype.onDestroy = function() { // Put time at normal speed this.game.time.slowMotion = 1.0; }
  14. Remove keyboard callback

    I have the same question. I'm adding a comment so I know when someone responds...
  15. Loading Images

    @brejep - I like it! Thank you. @o0Corps0o - hmmm... Interesting idea, but I can't picture how it would work.