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

Experimental Constructor Options #9535

Draft
wants to merge 5 commits into
base: v7.x
Choose a base branch
from

Conversation

bigtimebuddy
Copy link
Member

@bigtimebuddy bigtimebuddy commented Jul 10, 2023

⚠️ Work in progress

Trying out some more declarative constructor options for display objects. I feel like you should be able to set things like x/y from the constructor of display objects. Currently, only implemented Sprite, Container, DisplayObject.

const container = new Container();
const sprite = new Sprite(Texture.WHITE);
sprite.tint = 'red';
sprite.x = 100;
sprite.y = 100;
sprite.height = 200;
sprite.width = 200;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
sprite.alpha = 0.8;
container.addChild(sprite);
const container = new Container({
  children: [
    new Sprite({
       texture: Texture.WHITE,
       tint: 'red',
       x: 100,
       y: 100,
       width: 200,
       height: 200,
       anchor: { x: 0.5, y: 0.5 },
       alpha: 0.8,
    })
  ]
});

Demo:
https://jsfiddle.net/bigtimebuddy/m2rz5k18/

TODO

  • DisplayObject
  • Container
  • Sprite
  • AnimatedSprite
  • Text
  • HTMLText
  • Graphics
  • Mesh
  • ParticleContainer
  • BitmapText
  • TilingSprite

@bigtimebuddy bigtimebuddy added this to the v7.4.0 milestone Jul 10, 2023
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 10, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 796c39f:

Sandbox Source
pixi.js-sandbox Configuration

@bigtimebuddy
Copy link
Member Author

Here's another example with events:
https://jsfiddle.net/bigtimebuddy/mxaeq40o/

new Sprite({
  eventMode: 'static',
  cursor: 'pointer',
  onclick: () => console.log('clicked!'),
})

@Zyie Zyie added the 💞 Migrate to v8 This PR needs to be migrated to v8 label Jul 11, 2023
@bigtimebuddy bigtimebuddy removed this from the v7.4.0 milestone Jan 27, 2024
@Zyie Zyie deleted the branch v7.x March 5, 2024 17:16
@Zyie Zyie closed this Mar 5, 2024
@Zyie Zyie reopened this Mar 5, 2024
@Zyie Zyie changed the base branch from dev to v7.x March 5, 2024 18:06
@Zyie Zyie added v7 and removed 💞 Migrate to v8 This PR needs to be migrated to v8 labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants