How do I Keep Two objects near eachother

Get help using Construct 2

Post » Mon Mar 31, 2014 1:33 am

Essentially I am spawning objects that scroll down the screen. For the most part they spawn and stay where they are supposed to. But sometimes they will be too far apart. How can I bring the objects together?

Is there a way to check if a specific image point is in collision?
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Thu Apr 03, 2014 3:23 am

Bump.

And some better explanation.

I have two+ objects falling. I always want the object on top to be in contact with the object below it.

If there is a way to check if an image point is in the collision that would be great. Otherwise are there any other workarounds?

I spawn them and have them moving the same speed but over time these objects get further apart creating gaps.
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Thu Apr 03, 2014 3:35 am

Can you show an example don't understand what you mean?
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Apr 03, 2014 4:06 am

click and let it run for a little bit

I should mention I have been doing a good deal of optimizations, so it takes a minute or two before the issue happens. Out of ideas on improving it even further though.
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Thu Apr 03, 2014 4:17 am

Ok can see what you mean. However its hard to pin point where the problem is, how do you match them together?

Is it a set position to imagepoint or are they pinned?
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Apr 03, 2014 4:26 am

nimos100 wrote:Ok can see what you mean. However its hard to pin point where the problem is, how do you match them together?

Is it a set position to imagepoint or are they pinned?


Those rectangles at the top are spawners. They spawn to image points.

Everytime a line touches at the bottom it is destroyed and a new one is spawned.

My theory originally was as follows:
I have the objects spaced equally
The spawner and destroyer are also spaced evenly.

If I destroy an object and create it at the same step, then the spacing should remain true and have no gaps.

Obviously this does not work, or there are some pixel errors based on custom movement.

Now I need a way to adjust for this and prevent this gap from happening.

edit:
Another reason for error i imagine is as the objects get faster they might overlap the bottom destroying object and this creates offsets as well.
Last edited by Tylermon on Thu Apr 03, 2014 4:32 am, edited 1 time in total.
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Thu Apr 03, 2014 4:31 am

Think you misunderstood what I meant.

Im talking about the shapes that drops, how do you make them stick to each other? But from you description I assume that you don't, and you just apply the same speed to all of them?
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Apr 03, 2014 4:33 am

nimos100 wrote:Think you misunderstood what I meant.

Im talking about the shapes that drops, how do you make them stick to each other? But from you description I assume that you don't, and you just apply the same speed to all of them?


Exactly. Currently they are not stuck together. Only the same speed is applied
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Post » Thu Apr 03, 2014 4:50 am

Can you post the code might be easier. As I noticed it seemed to start lagging at the speed increased so maybe there are something not quite right?
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Apr 03, 2014 8:59 pm

nimos100 wrote:Can you post the code might be easier. As I noticed it seemed to start lagging at the speed increased so maybe there are something not quite right?


Essentially:

Code: Select all
On Line Created
{
Line speed= gamespeed;
}

Every 5 seconds
{
Gamespeed+=15;
Line speed= gamespeed;
}

Objects overlap(Line&EndLine)
{
Line.destroy;
line.create;
}
B
28
S
8
G
1
Posts: 226
Reputation: 2,865

Next

Return to How do I....?

Who is online

Users browsing this forum: adventurist and 40 guests