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

Bug: new Sprite gives me an error because the texture is not passed #10528

Closed
Tracked by #143
BlackRam-oss opened this issue May 12, 2024 · 1 comment · Fixed by #10532
Closed
Tracked by #143

Bug: new Sprite gives me an error because the texture is not passed #10528

BlackRam-oss opened this issue May 12, 2024 · 1 comment · Fixed by #10532
Assignees
Labels
🕷 Bug Verified that it’s actually a legit bug that exists in the current release. v8

Comments

@BlackRam-oss
Copy link

BlackRam-oss commented May 12, 2024

Current Behavior

it gives me an error. because the texture is not passed

Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'defaultAnchor')
    at _Sprite (/home/blackram/game-template/node_modules/pixi.js/src/scene/sprite/Sprite.ts:119:26)
    at <anonymous> (/home/blackram/game-template/src/values/locations.tsx:13:1)

Expected Behavior

that a blank texture is added by default. or force you to add a texture

Steps to Reproduce

new Sprite({
    x: 100,
    y: 100,
});

Environment

  • pixi.js version: 8.1.1
  • Browser & Version: Chrome
  • OS & Version: Windows

Possible Solution

const DEFAULT_OPTIONS = {
  // ...
}

class Sprite{
  constructor(_options = {}){
    const options = Object.assign({}, _options, DEFAULT_OPTIONS);
    // do stuff with the options, like set the sprite's coordinates
  }
}

Additional Information

No response

@BlackRam-oss BlackRam-oss changed the title Bug: Bug: new Sprite gives me an error because the texture is not passed May 12, 2024
@bigtimebuddy bigtimebuddy added 🕷 Bug Verified that it’s actually a legit bug that exists in the current release. v8 labels May 12, 2024
@bigtimebuddy
Copy link
Member

Thanks, this definitely is not intended. We should support undefined texture in the constructor. Suggestion is setting a default in the options destructure or reordering the default anchor line to be after the texture set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕷 Bug Verified that it’s actually a legit bug that exists in the current release. v8
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants