suggestion: deactivate instance outside layout

Discussion and feedback on Construct 2

Post » Sat Jun 14, 2014 7:12 pm

automatically deactivate instance when they are not inside the layout.
Disabled instances can not be chosen by infinite loop.
This saves the cpu and ram.
B
13
S
4
G
1
Posts: 107
Reputation: 1,337

Post » Sun Jun 15, 2014 3:06 am

Is this the sort of thing that you're after? The first condition ensures that the For-Loop will ignore those that are outside the layout....

inside layout selection.png
You do not have the required permissions to view the files attached to this post.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Tue Jun 17, 2014 10:46 am

This is not the intention of this thread.
Btw. in your example you still check all instances. "Is not outside layout" return true or false from every instance. And it need more cpu as a simply for each loop.
Whatever...
Just a suggestion for de-/activating instances feature. Scirra must decide whether they implement it.
To disable instances means efficient CPU usage. For example in a platform game. The instances (blocks, enemies, etc.) outside the screen eat cpu resources. An alternative: Create the level like a endless autoscroll runner. Buts its hard to handle for complex levels.
B
13
S
4
G
1
Posts: 107
Reputation: 1,337

Post » Tue Jun 17, 2014 2:44 pm

this could break projects where instances outside the layout is needed (simple exemple: an infinite runner where the player actually moves, which also helps a great deal with slopes compared to moving everything instead of the player), so it should be a choice by the user.

a "disable picked instances" would be better IMO than just the ones outside layout, also off screen instances aren't drawn, and if you disable their behaviors, and do what colludium suggested, they (off layout instances) won't be checked for everything put after that, and if really you need to disable them, destroying them I think is the way to go, I'm pretty sure this feature you are suggesting would actually do this destroying/recreating silently.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Tue Jun 17, 2014 2:46 pm

@DAG,

You misunderstand the event system. Have a look at this quick demo - the Not Outside Layout condition excludes the objects that are outside the layout from the subsequent For Each Loop. You can use this technique to filter other conditions either in single event blocks or in tiered / cascading events to minimize the cpu load. It's extremely powerful, IMO.

Edit - Otherwise you can use the outside layout check to deactivate them yourself manually, as Aphrodite said.
You do not have the required permissions to view the files attached to this post.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892


Return to Construct 2 General

Who is online

Users browsing this forum: Google [Bot], Tombas and 13 guests