Jump to content

Text not correctly sizing


chase12987
 Share

Recommended Posts

Below is my following code for effects in my game. As you can see i hard code 32px as the font size, yet no matter what size I put in be it 1px to 300px no difference is made. Any idea why the font is not sizing? Ignore the properties argument, implementing that later.

Effect = function(text, x, y, properties) {PIXI.Text.call(this, text, {font:'32px Press+Start+2P'}); this.position.x = x;this.position.y = y;this.z = 2; this.requestingRemoval = false;this.time = 0; console.log(this);}; Effect.prototype = Object.create(PIXI.Text.prototype); Effect.prototype.constructor = Effect; Effect.prototype.remove = function() {this.requestingRemoval = true;}; Effect.prototype.update = function() {this.time++;if (this.time >= 30) {this.remove();} this.position.y--;}; DamageText = function(text, x, y){Effect.call(this, text, x, y, {fill:'black'});}; DamageText.prototype = Object.create(Effect.prototype); DamageText.prototype.constructor = DamageText; var EffectHandler = {effects: [],addEffect: function(effect){this.effects.push(effect);}};

Further 

style: Objectalign: "left"dropShadow: falsedropShadowAngle: 0.5235987755982988dropShadowColor: "black"dropShadowDistance: 4fill: "black"font: "32px Press+Start+2P"stroke: "black"strokeThickness: 0wordWrap: falsewordWrapWidth: 100

So i can confirm that the 32px is being passed to the Font class.

 

In addition, my font loading code right from google

<!-- Fonts --><script type="text/javascript">  WebFontConfig = {   google: { families: [ 'Press+Start+2P::latin' ] } }; (function() {   var wf = document.createElement('script');   wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +     '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';   wf.type = 'text/javascript';   wf.async = 'true';   var s = document.getElementsByTagName('script')[0];   s.parentNode.insertBefore(wf, s); })(); </script>
Link to comment
Share on other sites

Two possibilities :

 

1 - The font ins't loaded yet when you create your PIXI.Text object. Fonts are loaded asynchronously so it can happens. You need to start your PIXI code after the WebFontLoader callback ( see https://github.com/typekit/webfontloader#events )

 

2 - The name of the font (with +) can't be parsed by PIXI. When this happens, PIXI uses a default Arial 30px font. Try with another font to check if this is your issue.

 

Regards.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...