Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't use "message.position.set(54, 96);" because it shows me an error in the browser's console. #68

Open
teodorattt opened this issue Aug 3, 2017 · 4 comments

Comments

@teodorattt
Copy link

teodorattt commented Aug 3, 2017

I copy-pasted the following code into my program:
var message = new Text(
"Hello Pixi!",
{fontFamily: "Arial", fontSize: 32, fill: "white"}
);

message.position.set(54, 96);
stage.addChild(message);

and it shows the following error in my browser's console:
Uncaught TypeError: Cannot read property 'set' of undefined

Can someone tell me what's undefined in my code?
Also, i have the whole code:

<!doctype html>

<title>Hello World</title> <script src="pixi.min.js"></script> <script type="text/javascript"> var type = "WebGL" if(!PIXI.utils.isWebGLSupported()){ type = "canvas" }
PIXI.utils.sayHello(type);

//Aliases
var Container = PIXI.Container,
autoDetectRenderer = PIXI.autoDetectRenderer,
loader = PIXI.loader,
resources = PIXI.loader.resources,
Sprite = PIXI.Sprite;
TextureCache = PIXI.utils.TextureCache;

//Create a Pixi stage and renderer and add the
//renderer.view to the DOM
var stage = new Container(),
renderer = autoDetectRenderer(256, 256);
document.body.appendChild(renderer.view);

loader
.add("images/myspritesheet.json")
.load(setup);

var sprite;

function setup() {

var texture = TextureCache["heart.png"];
sprite = new Sprite(texture);
sprite.y=30;
stage.addChild(sprite);
var message = new Text(
"Hello Pixi!",
{fontFamily: "Arial", fontSize: 32, fill: "white"}
);

message.position.set(54, 96);
stage.addChild(message);
gameLoop();

}

function gameLoop() {

requestAnimationFrame(gameLoop);
sprite.x += 1;
renderer.render(stage);

}
</script>

@coderD1mka
Copy link

Try this:
var message = new Text(
"Hello Pixi!",54,96,
{fontFamily: "Arial", fontSize: 32, fill: "white"}
);

@coderD1mka
Copy link

Or this:
var message = new Text(
"Hello Pixi!",54,96,
{fontFamily: "Arial", fontSize: 32, fill: 0xFFFFFF}
);

@coderD1mka
Copy link

And this one: new PIXI.Text(...)
You don't creating the alias for PIXI.Text like this:
var Text=PIXI.Text

@teodorattt
Copy link
Author

teodorattt commented Aug 9, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants