Making a sprite 'invisible' if its off-screen

  • I am trying to do something which seems simple, but for some reason isn't!

    I simply want to know how to make a sprite invisible if it is off the screen. There is a 'on screen' setting, but not an 'off screen'. Any ideas?

    Basically, I have a forest full of trees, all individual sprites. The game lags a lot though because there are hundreds of sprites. I simply want to try and make it so that all of the trees are invisible, unless the player is near them. That way, all the off-screen trees won't be using up memory...

  • 'Inverse'? No, what is that?

  • Ooh thanks, I wasn't aware of that option. It hasn't solved my issue but its good to know its there!

    I am now thinking I should set up some kind of boolean... so have the boolean set to true (visible) when on-screen, but set it to false at all other times...

    Still struggling to figure it out without an 'off-screen' setting:

    <img src="http://media.enigma-hosting.co.uk/enigma/SnowmanGame/forum-help/off-screen.jpg" border="0" />

  • FatRat : in cases like that, use the "Is on-screen" condition. Then, right click on it in the event tree, and click "invert".

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just add an 'is on-screen' condition, right click it and select 'invert'. Now it means 'is off-screen'.

    However, objects off-screen are already invisible. The engine does not attempt to draw any objects off-screen, so you won't gain anything by trying to do this yourself.

  • Thanks a lot for the tips. That 'invert' feature seems useful.

    So anything off-screen is automatically not used...thats interesting. I guess I need to come up with a different solution to my lag...

    thanks again :)

  • The trees really should be a tiled background or something. Place them manually in your image editor so you do not have 'hundreds of sprites'.

  • Yeah I agree it'd be better if they were a tiled background, but I wanted to create a forest that was a physical challenge to get through...so its hard to walk through the trees.

    See what I mean here:

    http://media.enigma-hosting.co.uk/enigma/SnowmanGame/

    I think I've pushed this as far as I can for now, so going to try a different approach altogether now...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)