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

Scene bindings #439

Merged
merged 4 commits into from
Jan 31, 2025
Merged

Scene bindings #439

merged 4 commits into from
Jan 31, 2025

Conversation

pgilfernandez
Copy link

@pgilfernandez pgilfernandez commented Jan 31, 2025

I've been playing with this for a while, I hope you like it.

I have implemented new bindings to take information from the active scene:

  • $sceneFPS (probably the most important and useful one)
  • $sceneWidth
  • $sceneHeight
  • $sceneStart
  • $sceneEnd

They are pretty explanatory 😉

What I don't know if it is the good way to do it or there is an easier one... Changing the names is easy so if you don't like this name convention let's discuss it.

I fixed a small bug that limited the binding name length to just 6 digits, take it into account.

The only "bug" I found is that if you have an expression with any of these new bindings and you change the Scene settings, the expression is not automatically updated... I guess this is simple, but I haven't done it.

Let me know about it 😄
Cheers

@rodlie
Copy link
Member

rodlie commented Jan 31, 2025

Cool, will take a look at the PR this weekend.

Changing the names is easy so if you don't like this name convention let's discuss it.

Maybe scene.value would be a better option? then we can add more sub values later.


While we are doing this, maybe see if we can reference other scenes (and children)? Maybe reference scene by name? like we do with object? That way we could do: scene_name.object_name.transform.etc

@pgilfernandez
Copy link
Author

Maybe scene.value would be a better option? then we can add more sub values later

Yes, that was the most logical way of doing it but I launched just the first and simplest way to do it... I don't know if I will be able to do as properties does as it is much more complex.

While we are doing this, maybe see if we can reference other scenes (and children)? Maybe reference scene by name? like we do with object? That way we could do: scene_name.object_name.transform.etc

Indeed, this would be the last step, hehehe, let's see if we can arrive there 😅

@rodlie
Copy link
Member

rodlie commented Jan 31, 2025

I simplified some code 41af7a2

@rodlie rodlie added enhancement New feature or request expressions labels Jan 31, 2025
@rodlie
Copy link
Member

rodlie commented Jan 31, 2025

Renamed the bindings to:

  • $scene.fps
  • $scene.width
  • $scene.height
  • $scene.rangeMin
  • $scene.rangeMax

Makes more sense IMHO.

@pgilfernandez
Copy link
Author

Indeed, that was my bet too.
I thought you were going to do something more complicated as with x and y inherit from traslate...

I didn't know you could include a dot in the binding name, hehehe.

But yes, much better this way 👏🏻

@rodlie
Copy link
Member

rodlie commented Jan 31, 2025

I thought you were going to do something more complicated as with x and y inherit from traslate...

Ideally we should do it this way, we reference whatever scene we want by property name and recursivly can go through scene properties and children properties etc scene_name.object_name.transform..., but for now just adding $scene is good enough (start).

@rodlie rodlie added this to the 1.0.0 milestone Jan 31, 2025
@rodlie
Copy link
Member

rodlie commented Jan 31, 2025

I think this PR is good enough for v1.0 (we can improve/add more features for v1.1). I don't see any issues/regressions with the changes. Will merge unless there are any objections.

@pgilfernandez
Copy link
Author

I do agree 🥳

@rodlie rodlie merged commit 5710e44 into friction2d:main Jan 31, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants