How do I align my object with its container

0 favourites
  • 6 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • 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

  • 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.

  • 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.

  • hmm so containers aren't suppose to sync automatically?

  • 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 ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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 ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)