How do I move a group of objects logically

Get help using Construct 2

Post » Fri Jul 07, 2017 5:58 pm

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 ?
B
6
S
1
Posts: 29
Reputation: 408

Post » Fri Jul 07, 2017 7:27 pm

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
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Fri Jul 07, 2017 8:41 pm

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

By the way, what is the sprite hotspot ?
B
6
S
1
Posts: 29
Reputation: 408

Post » Sat Jul 08, 2017 10:50 pm

conker23 wrote: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).
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sun Jul 09, 2017 12:19 pm

Ooook it's exactly what I figured out after trying different combinations. Thanks for your reply :)
B
6
S
1
Posts: 29
Reputation: 408


Return to How do I....?

Who is online

Users browsing this forum: troxx and 1 guest