0 Favourites

# How do I move a group of objects logically

• 5 posts
• Hi everyone,

I want to write fractions in a little game. They are composed of 3 parts : a fraction bar, a sprite text for the numeratr and a sprite text for the denominator. At the beginning the denominator and the numerator are set relatively to the fraction bar thanks to two image points.

I'd want to start with a tutorial for the player. So the fraction would be small at the beginning and then would smoothly go to a point I specified and getting bigger and bigger during the movement. The movement is done and the scaling as well, but I have an issue with this one.

When the bar is getting bigger, its image is bigger and bigger but it seems that the image points doesn't move proportionnaly to the place they used to be : they stay at the same place !

tl;dr : I'd like to get bigger two objects where one is set relatively to a second thanks to image point system. How do I hold the porpotionnal distance between them ?

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

Construct 3 users don't see these ads
• If the image point system doesn't work (don't know why though), I would simply go with some expressions.

If the Sprite is a simple bar, you can use the Bar coordinates and a percentage of its length to simulate an image point.

Let me give you some examples:

• Image point at 2/3 of the bar's length: X coordinate: Bar.X + Bar.Width * (2/3)
• Image point at 55% of the bar's length: X coordinate: Bar.X + Bar.Width * 0.55

(Assuming, the Sprite's hotspot is on its left.

If it's in the middle, use

Bar.X - Bar.Length/2 + Bar.Length * 0.55

for the second example)

Obviously use the Bar's Y coordinate for the Y coordinate of the simulated Image Point.

Hope this makes sense to you.

[EDIT]

@conker23 Here is a sample .capx

• It's make a lot of sense, thank you very much for that

By the way, what is the sprite hotspot ?

• By the way, what is the sprite hotspot ?

A Sprite's hotspot is its origin.

So when you use Sprite.X or Sprite.Y, C2 has to decide which of all the pixels on the Sprite represent its coordinates.

That's what the hotspot/origin does.

For Sprites, you can choose a hotspot everywhere on the Sprite (in the image editor).

But for dynamic graphics, like Tiled Backgrounds, your selection is restricted and you can only choose from 9 fixed points (in the object properties).

• Ooook it's exactly what I figured out after trying different combinations. Thanks for your reply

• 5 posts