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

Question about setting the scale of a stage #1232

Closed
RubrikBonnier opened this issue Dec 1, 2014 · 16 comments
Closed

Question about setting the scale of a stage #1232

RubrikBonnier opened this issue Dec 1, 2014 · 16 comments

Comments

@RubrikBonnier
Copy link

var stage = new PIXI.Stage;
//stage.scale = new PIXI.Point(2,5);
stage.scale = 2;

Whatever I try, I can't get it to change the scale (for zooming purposes). It appears to be fixed to the default. At first, I thought this would be the same as my first question, like stage.setScale(); or something, but I've looked everywhere and can't find anything like it.

Bonus question: are all the properties readonly?

@photonstorm
Copy link
Collaborator

Scale is a Point object, so the correct assignment would be: scale.set(2) - however this still won't achieve what you're expecting as the stage scale is ignored in the root transform. Your best bet is to create a single DisplayObjectContainer as your "world" and then add everything to that. Then you can scale and rotate and whatever you need on it.

@RubrikBonnier
Copy link
Author

Do you mean that I shouldn't use a stage, but a DisplayObjectContainer instead?

@photonstorm
Copy link
Collaborator

Not at all, the Stage has to exist - it's just it's a bit of an anomaly in that while it's the root of the display list, it can't be transformed in the same way. So if you add a single DoC to the Stage, and then put your entire game contents inside of that, you'll then be able to do the things you need like scaling and rotation.

@RubrikBonnier
Copy link
Author

var stage = new PIXI.Stage;
var actualWorld = new PIXI.DisplayObjectContainer;
stage.addChild(actualWorld);
...
Now I use actualWorld instead of stage everywhere, and... well... I'm getting weird errors.

@englercj
Copy link
Member

englercj commented Dec 1, 2014

Make sure you add all your items to actualWorld instead of stage. Can you be more specific about the errors you are getting, or have a live example?

@RubrikBonnier
Copy link
Author

I add all my stuff to actualWorlds instead of stage, yes. The error is weird: "Uncaught TypeError: Cannot read property '0' of undefined"
It's for one of the lines in the big minified Pixi.js file.

@photonstorm
Copy link
Collaborator

Use the non-minified Pixi file, then you'll get an actual error + line number you have a hope of working out while keeping your sanity :)

@RubrikBonnier
Copy link
Author

Using the non-minified Pixi file, it is revealed that this line is the crook:
gl.clearColor(stage.backgroundColorSplit[0],stage.backgroundColorSplit[1],stage.backgroundColorSplit[2], 1);

@englercj
Copy link
Member

englercj commented Dec 1, 2014

I'm honestly not sure without seeing your full codez :/

@RubrikBonnier
Copy link
Author

var stage = new PIXI.Stage;
var actualWorld = new PIXI.DisplayObjectContainer;
stage.addChild(actualWorld);
...
actualWorld.addChild(someSprite);

I only use "stage" in that very beginning. Using actualWorld for all places in my program where stage was used previously (where it worked).

@photonstorm
Copy link
Collaborator

Give the Stage a color:

new PIXI.Stage('#000000');

@RubrikBonnier
Copy link
Author

Unfortunately, giving it a color like you showed didn't have a difference. Same error, same line.

@englercj
Copy link
Member

englercj commented Dec 2, 2014

Can we see a running example of your code and try to figure out what is wrong?

@photonstorm
Copy link
Collaborator

Opps, too used to Phaser :) Try this:

new PIXI.Stage(0x000000);

@RubrikBonnier
Copy link
Author

This issue is no longer relevant due to help received in a different one. I did try to add what you said above, but I get a black screen if I change the scale of the "root". I will have to ask this differently with my new knowledge, later.

@lock
Copy link

lock bot commented Feb 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants