How do I spawn object between 2 images ?

Get help using Construct 2

Post » Fri Jun 05, 2015 7:21 am

Let's say that the question mark is image1 and the exclamation mark is image2.

:?:.............................:!:

I need to spawn an object between those 2 images. Any ideas ?
B
14
S
2
Posts: 35
Reputation: 789

Post » Fri Jun 05, 2015 10:19 am

Ok, I'll call "A" the 1st image and "B" the 2nd one.

If the images will be always on the same place you can just create the object at the X and Y that is between those images.

If the images change places try this;
Create object at
x = A.x < B.x ? A.x + (B.x - A.x)/2 : B.x + (A.x - B.x)/2
y = A.y < B.y ? A.y + (B.y - A.y)/2 : B.y + (A.y - B.y)/2

What this is doing is:
(A.x < B.x ?) > Is A.x smaller than B.x? In other words is image A on the left side of image B?

If it is then X will be the part of the code between the "?" and the ":"
So "x = (A.x + (B.x - A.x)/2)" Which is the same distance from the origin as the image A plus half the distance between A and B.

If it is not then X will be the part of the code after the ":"
So "X= B.x + (A.x - B.x)/2" Which is the same thing as before but considering B is on the left side of A

The code for Y is exactly the same.

Of course this codes will create the image always in the exact center between images A or B. To create objects anywhere between the A and B the code should be different.

I'm not sure if this is the best way to do it, but it's how I would do it. Hope it helps ;)
B
17
S
7
Posts: 280
Reputation: 2,522

Post » Fri Jun 05, 2015 12:51 pm

You could also do:

X = (A.x+B.x)/2
Y = (A.y+B.y)/2
B
63
S
19
G
8
Posts: 341
Reputation: 12,130

Post » Sat Jun 06, 2015 2:47 pm

Try this tutorial link below. Many tutorials here for you to learn

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,753


Return to How do I....?

Who is online

Users browsing this forum: mikehive, tinhofiel and 35 guests