On start of layout / loops, logic, collsions?

Get help using Construct 2

Post » Wed Jan 09, 2013 8:49 pm

Hi all,

having a question concerning "on start of layout"....

At the start of a new Level, I'd like to put some objects at random locations on the layout, like crates or other obstacles (for some kind of top down shooter game).

- objects should be picked from a range of suitable objects.

- objects should have a random rotation, probably slightly variations of size.

- objects should have a certain distance to each other, to make sure that they can't form unreachable areas. (Probably using collision detection to check?)

- if this would be visible for the user (maybe it takes some time, like half a second or so), it would be good to hide the process somehow.

So far, I'm able to set one kind of objects at random locations, with "on start of layout" and a for loop, and give them a random rotation. However, the objects overlap, and when I try to check for collisions to destroy the overlapping ones, they all vanish. It only works if I pick one of these objects randomly (not on start of layout, but every frame) and check for collisions, but that's not a good way to do things, I guess...

can somebody please give me a hint how to do this at layout start?




B
3
Posts: 2
Reputation: 329

Post » Wed Jan 09, 2013 9:15 pm

Not sure which licence you have, but families can generate different objects very easily. Otherwise you'll have to replicate the functionality by randomly choosing an object inside the loop.

For the collision stuff, it goes something like this: object is overlapping object, pick instance 1 -> object.destroy, optionally recreate the object when you're done. This will flicker the objects slightly so you might want to hide the process from the player.

capx
B
56
S
15
G
10
Posts: 910
Reputation: 11,952

Post » Wed Jan 09, 2013 9:25 pm

Hi Geometrix,

Thanks a lot! I'm fairly new and right now, toying around with the free edition.

What I do not understand is, why do You re-create the objects in Your example?
B
3
Posts: 2
Reputation: 329

Post » Thu Jan 10, 2013 8:18 am

Are you referring to the objects I have parked off to the side of the layout? That's a thing with Construct, you need to have at least one instance of all objects at least somewhere in your project before you're allowed to spawn new instances of them.

It's sufficient to place those dummy instances off to the side of the layout (where the player won't see them), or you can create an entirely new layout (I like to call mine "Parking lot") for them. You'll find that as your project grows, you'll probably have quite a few of these objects set off to the side.

EDIT: Oh, wait, unless you're referring to the actions in event 3, in which case I'm re-creating objects that were previously destroyed, just so that I've always got 10 instances of the object.GeometriX2013-01-10 08:24:20
B
56
S
15
G
10
Posts: 910
Reputation: 11,952


Return to How do I....?

Who is online

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