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

Texture Error: frame does not fit inside the base Texture dimension #69

Open
sidd-92 opened this issue Aug 19, 2017 · 1 comment
Open

Comments

@sidd-92
Copy link

sidd-92 commented Aug 19, 2017

In the 7th File when i run the code an issue regarding Texture dimension appears.

Texture Error: frame does not fit inside the base Texture dimensions: X: 192 + 64 > 192 Y: 128 + 64 > 192.

How do you resolve this issue?

@chawk
Copy link

chawk commented Jan 28, 2020

The parameters for the rectangle are wrong. This is an example of how to do it.

import * as PIXI from 'pixi.js'

let Application = PIXI.Application,
    Sprite = PIXI.Sprite,
    Rectangle = PIXI.Rectangle,
    Texture = PIXI.Texture;

//Create a Pixi Application
let app = new Application({
    width: 256, 
    height: 256
});

app.renderer.backgroundColor = 0x061639;

const loader = app.loader;

loader.add("../public/img/tileset.png")
    .on("progress", loadProgressHandler)
    .load(setup);

function setup() {
  let tilemap = Texture.from("../public/img/tileset.png");

  //Create a rectangle object that defines the position and
  //size of the sub-image you want to extract from the texture
  //(`Rectangle` is an alias for `PIXI.Rectangle`)
  let rectangle = new Rectangle(96, 64, 32, 32);

  //Tell the texture to use that rectangular section
  tilemap.frame = rectangle;

  //Create the sprite from the texture
  let rocket = new Sprite(tilemap);

  //Position the rocket sprite on the canvas
  rocket.x = 32;
  rocket.y = 32;

  //Add the rocket to the stage
  app.stage.addChild(rocket);

  //Render the stage   
  app.renderer.render(app.stage);
}

function loadProgressHandler() {
    console.log("loading"); 
}

//Add the canvas that Pixi automatically created for you to the HTML document
document.body.appendChild(app.view);

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