How do I align my object with its container

Just started using Construct 2? Post your questions here

Post » Mon Apr 11, 2016 2:26 am

How do I align my object with its container?
I have a thruster object that goes with a ship object but it needs to be aligned correctly
I have tried editing the sprite and moving the origin point around but it still seems to snap with the center of my ship object
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Mon Apr 11, 2016 4:01 am

Hi,
Can you update your project (or just the part of your project) ? I don't understand what do you mean. (You must use "everytick" and 'set Sprite 2 position to " then you can set position using Sprite1.X and Sprite1.Y & Sprite1.Width and Sprite1.Height)
I will do this event for you because it's short.
Excuse me for my bad english, I'm french.
B
17
S
10
G
19
Posts: 140
Reputation: 11,457

Post » Mon Apr 11, 2016 8:40 am

Leave the origin alone. (unless you need to object to rotate arround something else then the centre)

Instead. In the same window as you move the origin you see a big +. Click it to make a new ImagePoint.
Name it as you like. Remember its number.
Now with it selected in the list of image points, move it to where you want it.
Close the imagepoints windows before you close the sprite editor.

Now, when you set the position of de truster. The X value will be ship.ImagePointX(number). Or ImagePointX("name"), as you like. The Y value will be ship.ImagePointY(number).

Hope this helps you.
B
33
S
18
G
27
Posts: 2,435
Reputation: 20,334

Post » Mon Apr 11, 2016 9:59 pm

hmm so containers aren't suppose to sync automatically?
B
13
S
6
G
1
Posts: 149
Reputation: 1,960

Post » Mon Apr 11, 2016 10:20 pm

If one object in a container is created, every other object in its container is also automatically created.
If one object in a container is destroyed, every other associated object in its container is also destroyed.
If a condition picks one object in a container, every other associated object in its container is also picked.

Sync ?
B
33
S
18
G
27
Posts: 2,435
Reputation: 20,334

Post » Mon Apr 11, 2016 11:16 pm

Suppose you made a container with in it a ship, a truster and a radar.

Rule 1:
When you create a ship. A truster and a radar will be created on the same position as the ship.
Yes you can calculate and reposition the origins of the truster and the radar so they will fit where you want them.
Origins can be way outside the sprite. That will work (besides that you will have trouble rotating truster and radar)

If that is a good practic, i let you decide.

Rule 3 is also present in rule 1. Because after creation, the created object will be in picklist. Hence, it is a pick action.

Rule 2:
Is what it says.

Rule 3:
If you pick a particulair ship, based on conditions, the right truster and the right radar are also in the picklist.
Any action targetted to that particulair ship, will only target that ship. Moving that ship will not move the others. No sync. But, the right truster and radar is picked. You do not have to make a new pick event. That is what the rule says.

Meaning, you have to move them anyway. Can as well move them on creation too whit exact the same actions.

Rule 0:
But why fiddle with the origins? If you still have to move things anyway.
Can as well use imagepoints, you directly see where they are on the sprite that matters. And origins stay where you might need them to easely rotate.

But it is up to you. Althought, did't you say dat moving the origins is not that easy ?
B
33
S
18
G
27
Posts: 2,435
Reputation: 20,334


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest