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

Example code does not work #31

Closed
BarsikTheCaT opened this issue Nov 10, 2016 · 9 comments
Closed

Example code does not work #31

BarsikTheCaT opened this issue Nov 10, 2016 · 9 comments

Comments

@BarsikTheCaT
Copy link

BarsikTheCaT commented Nov 10, 2016

PIXI.loader .add("pictures/Mech1Walk.png") .load(setup);
(why did author omit PIXI. prefix???)
`function setup() {
var texture = PIXI.TextureCache["images/tileset.png"];

var rectangle = new PIXI.Rectangle(1, 1, 64, 64);

texture.frame = rectangle;

var robot = new PIXI.Sprite(texture);

robot.x = 100;

robot.y = 100;

stage.addChild(robot);

renderer.render(stage);

}`

Gives me this error:
Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at ... (path to my picture);

@evolveinua
Copy link

Because this manual - a piece of deprecated shit >_<
For example, i have a troubles with simple task - create triangle. And... Console told me "Graphics is not defined". All i need is a simple triangle. And this doesen't work! Hate-hate-hate.

@GoodBoyDigital
Copy link

HI @evolveinua , I can understand that you are frustrated but you must be careful not to direct it at the people who can help. This guide is great and has helped out many pixi users, you must remember that @kittykatattack has made this guide for free of his own back so really he owes us nothing.

Instead it will be better to work together to figure out the issue and find a solution to your problem so that we can then share it with the community. If you can share your code I'm sure we can help to solve the issue.

Cheers

Mat

@lbpage
Copy link

lbpage commented Dec 10, 2016

i would suggest you use chrome dev editor chrome dev editor you can import your js test into this. As the tutorial says the pixi.js items require a webserver this is because the CORS policy blocks loading file resources directly from local storage reference issue

@kittykatattack
Copy link
Owner

@evolveinua Yes, programming can be very frustrating! But we're here to help, so if you can break down your questions into smaller steps or provide us some examples of your course code, we'll do our best to help walk you through the problems you're having 😄.

@ickyrr
Copy link

ickyrr commented Mar 21, 2017

Hi, @kittykatattack I'm having the exact same problem. I'm still new to PIXI so I don't really understand the issue. Can you help me out? I only have the code shown in the tutorial.

var stage = new PIXI.Container(),
    renderer = PIXI.autoDetectRenderer(256, 256);
document.body.appendChild(renderer.view);

//Use Pixi's built-in `loader` object to load an image
PIXI.loader
  .add("images/cat.png")
  .load(setup);

//This `setup` function will run when the image has loaded
function setup() {

  //Create the `cat` sprite from the texture
  var cat = new PIXI.Sprite(
    PIXI.loader.resources["images/cat.png"].texture
  );

  //Add the cat to the stage
  stage.addChild(cat);
  
  //Render the stage   
  renderer.render(stage);
}

Thanks!

@kittykatattack
Copy link
Owner

@ickyrr Hi! Are you running your code inside a web server?

@ickyrr
Copy link

ickyrr commented Mar 22, 2017

@kittykatattack , yep, I was, previously. I was too tired I did not think of webpack dev server much sooner. It works now, thanks! A great tutorial BTW.

@kittykatattack
Copy link
Owner

Great news! 😄

@rajasekharsurineni
Copy link

@kittykatattack i am new to pixi and getting error Failed to execute 'texImage2D' on 'WebGLRenderingContext': The image element contains cross-origin data, and may not be loaded. while loading image .what i has to do

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

No branches or pull requests

7 participants