Object Optimize

Get help using Construct 2

Post » Fri Sep 13, 2013 10:17 pm

Hey guys,

My game has +100 objects the objects is the same sprite. I am making this game for mobile devices so such an object count like that can causing lag and fps drops.

I want to create this objects when they are on screen. When they are off screen, they will be destroyed.

I tried to do this with on-screen but it doesn't work, individually. And I have tried destroy them due to players.Y with object.UID, it takes lots of time but it works. However I can't create object using this way and even I create objects the UIDs will change then I can't destory them.

Is there a way or plugin to create objects when they are on-screen and destory them when they are off-screen ?


Thanks for taking time.
bilgekaan2013-09-13 22:36:47
Image
B
71
S
34
G
39
Posts: 432
Reputation: 24,993

Post » Fri Sep 13, 2013 10:28 pm

There's an Is On-Screen condition, just invert that.EncryptedCow2013-09-13 22:28:49
B
47
S
14
G
7
Posts: 603
Reputation: 8,141

Post » Fri Sep 13, 2013 10:35 pm

@EncryptedCow

My objects are the same sprite so it won't work for me. When I said

X is not on-screen -> Destroy

It destroys all X not just off-screen ones.bilgekaan2013-09-13 22:36:23
Image
B
71
S
34
G
39
Posts: 432
Reputation: 24,993

Post » Sat Sep 14, 2013 12:24 am

You could try for each object destroy when invert on screen. I think for each picks them one by one.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Sat Sep 14, 2013 12:41 am

Check their position in relation to viewports, and then destroy accordingly.

For Each Object
    Object X < ViewportLeft -> Destroy object.
    Object X > ViewportRight -> Destroy object.
    Object Y < ViewportTop -> Destroy object.
    Object Y > ViewportBottom -> Destroy object.Excal2013-09-14 00:42:17
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Sat Sep 14, 2013 9:32 am

Thanks for replies,

@Windwalker it destroys all object.

@Excal

Object Y < ViewportTop -> Destroy object.

It works but

Object Y > ViewportBottom -> Destroy object.

this destroys all objects. The layout size 320*6000.
Image
B
71
S
34
G
39
Posts: 432
Reputation: 24,993

Post » Sat Sep 14, 2013 9:40 am

[QUOTE=bilgekaan] @EncryptedCow

My objects are the same sprite so it won't work for me. When I said

X is not on-screen -> Destroy

It destroys all X not just off-screen ones.[/QUOTE]

You have something wrong with your events then. Here is an example: Destroy object offscreen
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Sat Sep 14, 2013 10:48 am

@vee41 thanks for the capx

It seems I did something wrong
Image
B
71
S
34
G
39
Posts: 432
Reputation: 24,993


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 59 guests