Comments (19)
AFAIK there is no "Clicking Idiom" in ECS. @matiwinnetou correct me if I am wrong.
Clicking is something we desperately need though, I am a big fan of the propagation model from javascript/html
though.
Would you mind if I took this PR?
from engo.
Be my guest. 👍
from engo.
@EtienneBruines what are your thoughts on implementing this handler at the World
level?
from engo.
A ClickSystem
, together with ClickComponent
s.
If an Entity
has a ClickComponent
, the ClickSystem
will use the SpaceComponent
and Mouse
values to see if it's being clicked, and if so, either set some value at ClickComponent
to CLICKED
, or perhaps dispatch some Message
?
Misread your message. At the World
level... hmm. They'd have to register some kind of OnClick
event, but who should do that? System
s could do that, I guess.
Or just dispatch a Message
, and then everyone can Listen
for those messages if he/she pleases?
from engo.
@EtienneBruines I think implementing this as a System
is a good idea. Although, if we do this we may as well remodel the way key input works as well.
I believe going with the messaging model for this would serve us best.
from engo.
Well, with keys the state is kinda important: just clicked, holded, released, etc. And combinations of keys.
A click
is simply a click
.
from engo.
@EtienneBruines state can actually be important for click
s too.
Imagine a button: You want to act when the button has been released!
Imagine a shooting game: You want to act when the button is first pressed, and perhaps when it is continuously held down.
Either way however, this is irrelevant (for both clicks and key presses). Data can be transferred within a message which could be used to contain the state.
engi.Mailbox.Listen("ScoreMessage", func(message engi.Message) {
scoreMessage, isScore := message.(ScoreMessage)
if !isScore {
return
}
sc.scoreLock.Lock()
if scoreMessage.Player != 1 {
sc.PlayerOneScore += 1
} else {
sc.PlayerTwoScore += 1
}
log.Println("The score is now", sc.PlayerOneScore, "vs", sc.PlayerTwoScore)
sc.upToDate = false
sc.scoreLock.Unlock()
})
from engo.
Good point. Messages are kinda cheap anyway, so we could do that, yes.
from engo.
Thoughts @matiwinnetou?
from engo.
(We should also note that this should indeed also cover things like hover
)
from engo.
Have you already started working on this, or can I create something with a ClickSystem
and ClickComponent
, which has some states (i.e. Clicked
, Hovered
, Focused
, etc.)?
(I'm making a little game, and am in need of this; don't want to rush you, but also don't want to wait if you don't have time for it anyway; again: I do not mean this in a negative way, whatsoever. 😄 )
from engo.
@EtienneBruines feel free to take this.
from engo.
Tricky; currently at "how to handle zooming", and "how to handle scrolling to the sides".
The very basics work.
from engo.
👍
On Fri, Nov 27, 2015 at 8:20 AM Etienne Bruines [email protected]
wrote:
Tricky; currently at "how to handle zooming", and "how to handle scrolling
to the sides".The very basics work.
—
Reply to this email directly or view it on GitHub
#59 (comment).
from engo.
Current status:
TODO
- Rightclick.
from engo.
Etienne, Paked,
I am using the current head from paked/engi and I am using the MouseSystem and MouseComponent to handle clicks on a HUD entity of mine.
At the moment I note that the mouse component does not give me access to the "Mouse Released" event. If I try to use the mc.Clicked against my entity I receive a lot of events (I assume this is normal because my poor fingers are not quick enough to compete against 120fps...) and I'd like to receive only one because each click will launch actions and cost resources. I can (and did) implement some kind of filter based on timing but I find it brittle and error prone.
I would like to make the "mouse released inside your entity" available through the MouseComponent as mc.Released. I don't see the big picture yet so it is possible this event does not make a lot of sense and a better solution already exists... please just let me know if this is the case.
What do you think of it? If you are interested I'll propose a PR.
BTW I added to this issue instead of opening a new one because of the "click system" focus of my question
from engo.
@faide If you want to take a crack at this, I'd be happy to review the pull request!
from engo.
@paked I did first run here: #146
from engo.
Correct me if I'm wrong, but #146 fixed this.
from engo.
Related Issues (20)
- Determine the screen resolution of an application HOT 2
- gl package vs pure Vulkan rendering
- Get Font Via URL
- Export current frame in the Animation Component
- Update isometric demo to use tiles of different sizes
- WSL to build on windows
- Shape drawing problem HOT 7
- Circle fill transparency HOT 6
- About performance HOT 7
- Scale operation seems to move the entity to the wrong position
- shader
- Support WebGL and Android HOT 11
- TMX resources cannot handle tile sets that leave a rest at end of rows HOT 2
- TMX resources don't respect transformations when loading tiles
- Build on macos M1 / Apple Silicon fails (GL/mobile-related) HOT 2
- AudioSystem's Pause and Restart aren't working
- Question: Can you draw upon a transparent window/canvas? HOT 1
- Cannot Compile on m1 mac HOT 3
- Release v1.0.7 appears to be tagged incorrectly HOT 1
- Properly handle gifs
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 engo.