flame
flame copied to clipboard
Add orientation property do PositionComponent
What could be improved
New property double orientation; will keep track of where the component is "looking at": is it naturally pointing up, or down, or left, or right? It's easier (and more flexible) to have this as a double and not enum.
Maybe there is a better name for it too.
Why should this be improved
The PositionComponent currently consists of size, anchor, and transform (where transform has position, rotation, and scale). What it's missing is the notion of a natural direction.
Use cases:
- allow
PositionComponent.angleTo()method which computes the angle between this component's natural direction and another given component; - allow
RotateEffect.towards()which can rotate the component so that it would "look at" another component.
Any risks?
No.
Sounds like a very good addition!
The orientation needs to be defined from some point too right, would this be up or right defined, like where is 0?
Since this wouldn't be a breaking change it could be done post v1.
Isn't that the same as angle?
angle measures rotation from the original position. This property tells you what the original orientation is (relative to the screen).
This seems like angle to me... and then both angleTo and lookAt are derivates of that plus some external input.
I wonder what we could name this, I feel that orientation might be a bit confusing.
Maybe one of these (not completely convinced by any of them though so please add more suggestions if you have any):
initialAngleinitialOrientationstartAngle...
As this new property is just going to offset the actual angle, calling it angularOffset would be appropriate. Words like initial and start make it seem like it gets applied only at the beginning and not throughout the lifetime of the component.
nativeAngleintrinsicAngle
I think it's best to stick to the naming pattern "*Angle", to make it clear that this property is a kind of angle and not anything else.
nativeAngle is the best one so far I think.