Cyxo Posted December 7, 2015 Share Posted December 7, 2015 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... Quote Link to comment Share on other sites More sharing options...
mattstyles Posted December 8, 2015 Share Posted December 8, 2015 You dont need to compile Pixi, it comes built. If you have node installed you can just donpm i -S pixi.jsIf you are using something like browserify or webpack that gives you commonJS modules for your client code then you can usevar PIXI = require( 'pixi.js' )or pixi can attach globally usingrequire( '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 Quote Link to comment Share on other sites More sharing options...
Cyxo Posted December 8, 2015 Author Share Posted December 8, 2015 Ok, that works now. Thank you very much ! Quote Link to comment Share on other sites More sharing options...
Cyxo Posted December 9, 2015 Author Share Posted December 9, 2015 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) Quote Link to comment Share on other sites More sharing options...
xerver Posted December 9, 2015 Share Posted December 9, 2015 You can use any custom font with pixi, it just has to have been loaded before you draw with it. This is a browser limitation, not a Pixi limitation. Look for font loaders. Quote Link to comment Share on other sites More sharing options...
Cyxo Posted December 9, 2015 Author Share Posted December 9, 2015 Ok, and what is the best font format ? Woff ? (I currently have woff, ttf, otf, eot and svg) Quote Link to comment Share on other sites More sharing options...
mattstyles Posted December 9, 2015 Share Posted December 9, 2015 http://caniuse.com/#search=woff woff looks good (although ttf/otf are ordinarily better), something like font squirrel can pack a font for web use (many fonts look rubbish on the web, it wont help with that but it will make them work) Quote Link to comment Share on other sites More sharing options...
Cyxo Posted December 10, 2015 Author Share Posted December 10, 2015 Ok, that worked ! Thank you very much for your help, guys ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.