Comments (3)
Can you provide a minimal crashing sample?
from entityx.
Try running the tests and following what they do. This definitely works.
from entityx.
I figured out the problem. I was trying to add a component to an entity that already had one. Here's the working version.
void update(entityx::EntityManager &entities, entityx::EventManager &events, entityx::TimeDelta dt) {
if (isSelecting) {
renderer.render(selectionColor);
entities.each<Position>([this](entityx::Entity entity, Position& position) {
auto pos = position.value;
bool isSelected = false;
if (pos.x > selection.minX && pos.y > selection.minY && pos.x < selection.maxX && pos.y < selection.maxY) {
if (!entity.has_component<Selection>()) {
entity.assign_from_copy<Selection>(selection);
}
isSelected = true;
}
if (!isSelected && entity.has_component<Selection>()) {
entity.remove<Selection>();
}
});
}
}
It would probably be a good idea to add some mention of the has_component
to the component section.
Great library btw!
from entityx.
Related Issues (20)
- Cross compile with target_complie_feature error HOT 2
- Assertion failed when trying to add system HOT 3
- Assertion failure when removing a component while an entity is being destroyed
- family_counter_ issues when using EntityX as a shared library HOT 6
- UUIDCollisionResolver HOT 2
- [Question] Select components based on a specific variable value HOT 1
- Can't use entityx in Qt : conflicts with simplesignal HOT 2
- Some little requests~
- Future of entityx HOT 5
- more efficient way of looping trough a bunch of classes? HOT 1
- Passing an entity as a pointer (Question) HOT 11
- Catch::AssertionInfo& Issues Preventing Build HOT 1
- Inherited Component Polymorphism? HOT 2
- Grabbing access to the entity that owns a component? HOT 1
- Inheriting from Entity? HOT 1
- Issue with install from vcpkg
- Shared library not working in Windows HOT 1
- Entity creation / destruction slows down over time? HOT 15
- Does this project have DOP optimization? HOT 1
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 entityx.