Tour Preview

Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › Visibility of an entity

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18585

    Marcin

    Hi,
    Have a question about entity and when is it visible.
    In my scenario I have many entities outside of what user can see, basically “outside” of scene(lest say y position is -1000), for example.
    The problem is Qt still recognizes this entity as visible.
    Is there an easy to way to tell if entity is really visible, like on the screen?
    Or I need to do things like bodyAt to find the x and y if there are visible to the user.

     

    I have some logic which should work only when entity is visible, but it works when user doesn’t see the entity just yet, so that causes some issues.
    I am also concerned about performance.
    From what I know Qt doesn’t execute some operations for entity if it’s not visible, in this case(entity not visible for user) those optimizations are not active but they should?

    #18588

    Alex
    Felgo Team

    Hi Marcin,

    since you are already using physics, I’d recommend using a sensor collider. You could either add 4 colliders at the edges (or rather a bit outside) of your screen, or a single one filling (or even a bit bigger) your screen.

    For the latter option, as soon as your entity collides with the sensor you know it enters the screen, and as soon as collision ends it left the screen. With 4 distinct colliders you will need some more logic to know if it either entered or left the screen.

    Physics uses all C++ behind the scenes, thus this will have better performance than running checks from QML on every frame.

    Is this sufficient for your use case?

    Cheers,
    Alex

    #18592

    Marcin

    Hi Alex,
    Thank you for hint.
    Will look closer into it.

    #23655

    OCG

    I like the idea of a sensor the size of the screen (or a bit bigger).  However, since the screen can be so many different sizes (and even change if someone changes resolution), how do you define such a sensor?

     

    Could you provide a code snippet to show this?

     

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.