Comments (2)
Reasons for exporting the GUIComposite:
- Getting a texture from it
- Getting a font from it
from raven.
The new standard will be either to pass the layer's context
argument to the components that use it, or to get the textures/fonts from the context and pass them to the components.
Example with a context
argument:
export class BlackSquareLayer extends Layer {
/**
* @param {GUIComposite} context
*/
build(context) {
return new BlackSquare(context);
}
}
export class BlackSquare extends VisualComponent {
/**
* @param {GUIComposite} context
*/
constructor(context) {
super({
alignment: Alignment.left | Alignment.top,
size: new Vector2(64, 64),
texture: context.getTexture("black"),
});
this.setSubcomponents([
new Subcomponent({
size: this.getSize(),
}),
]);
}
}
Example with the textures/fonts retrieved in the layer, then passed to the component:
export class BlackSquareLayer extends Layer {
/**
* @param {GUIComposite} context
*/
build(context) {
const blackTexture = context.getTexture("black");
return new BlackSquare(blackTexture);
}
}
export class BlackSquare extends VisualComponent {
/**
* @param {TextureWrapper} texture
*/
constructor(texture) {
super({
alignment: Alignment.left | Alignment.top,
size: new Vector2(64, 64),
texture,
});
this.setSubcomponents([
new Subcomponent({
size: this.getSize(),
}),
]);
}
}
from raven.
Related Issues (12)
- Group position not computed on resize events
- Invisible textures on Firefox
- Resize doesn't work properly since text color has been added
- Error when disposing the GUI manager HOT 1
- Slow texture loading HOT 1
- Font is not assignable to BitmapFont HOT 1
- Convert Error functions to ES6 classes
- Add Vector.isNull()
- Composite and subcomponent shaders
- Generic components (Sprite, Text...)
- WebGL shader API
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raven.