Making a sprite 'invisible' if its off-screen

Get help using Construct 2

Post » Thu Nov 03, 2011 11:54 am

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...
B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Post » Thu Nov 03, 2011 12:01 pm

'Inverse'? No, what is that?
B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Post » Thu Nov 03, 2011 12:34 pm

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:

B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Post » Thu Nov 03, 2011 1:10 pm

@FatRat : in cases like that, use the "Is on-screen" condition. Then, right click on it in the event tree, and click "invert".
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Thu Nov 03, 2011 1:12 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Nov 03, 2011 2:24 pm

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 :)
B
16
S
5
G
2
Posts: 20
Reputation: 2,227

Post » Thu Nov 03, 2011 8:00 pm

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'.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Fri Nov 04, 2011 10:19 am

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...FatRat2011-11-04 10:19:35
B
16
S
5
G
2
Posts: 20
Reputation: 2,227


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 17 guests