Jump to content

PIXI.Text error


Cyxo
 Share

Recommended Posts

 

Hi,

 

When I try to use create text (with this code http://pixijs.github.io/examples/index.html?s=basics&f=text.js&title=Text ), it doesn't do anything. I also get an error message in my JS console saying : Uncaught TypeError: PIXI.Text is not a function (using Chrome)

 

Can you help me ?

 

PS: As I can't compile Pixi.js (to many Node.js/NPM problems), I had to take the one from this site : http://gametest.mobi/pixi/morph/pixi.js (site available on Pixi.js examples, under Demos - photonstorm's Morph Demo), but maybe he excluded some functions from Pixi before compiling...

Link to comment
Share on other sites

You dont need to compile Pixi, it comes built. If you have node installed you can just do

npm i -S pixi.js

If you are using something like browserify or webpack that gives you commonJS modules for your client code then you can use

var PIXI = require( 'pixi.js' )

or pixi can attach globally using

require( 'pixi.js' )

Of course, if you arent using that then use the download links on the homepage or the github repo and simply include the `pixi.min.js` file  in the page which will give you a big fat global `PIXI`. You can still just include the script in the page using npm, install it first and then `<script src="node_modules/pixi.js/bin/pixi.min.js">` and you're good to go. No need to grab it from some other source, there are plenty of ways from the homepage.

 

edit: infact, `var pixi = require( 'pixi.js' )` will dump to global as well which is naughty naughty

Link to comment
Share on other sites

 

Well I'm now having another problem with Pixi text (I post it here because the topic's title still match this problem). I know it caused a lot of trouble to people trying to do this, but I need to you use a custom font.

I tried using the CSS @font-face method, but the text is still in Times font.

I learned about bitmap fonts, but I don't know how to load them in my script using the new loader (the only available example uses the old, deprecated assetsLoader).

 

So what's the best way to use custom fonts with Pixi ? (Note: I have to be able to get the width of the generated text)

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...