Ginesis
September 29, 2021, 9:29pm
#1
How to center a modified dynamically object in relation to another.
eg:
-object 1: a square
-object 2: a text that is modified with a variable
-desired result: center modified text in the square
This does not center:
change the position of text = square.X("")-text.Width()/2 (x axis), =square.Y("")-text.Height()/2 (y axis)
An idea?
MrMen
September 29, 2021, 9:52pm
#2
Is the origin of square/object1 in the centre of the image?
Almost there maybe you need to do
change the position of text = square.X(“Center”)-text.Width()/2 (x axis), =square.Y(“Center”)-text.Height()/2 (y axis)
Ginesis
September 29, 2021, 10:10pm
#4
Yes, my image is 64*64
Origin points: X=32 Y=32
Ginesis
September 29, 2021, 10:10pm
#5
It’s the same result
square.X(“Center”) is the same than square.X(“”) because my origin points are the centre
Ginesis
September 29, 2021, 10:18pm
#6
I manage to center an initial text to display, but this text is no longer centered when it is dynamically modified with a variable
MrMen
September 29, 2021, 10:31pm
#7
What do you mean by dynamically modified? As in the text is set to the value of a variable?
If so, do you centre the text after it’s been modified?
1 Like
Ginesis
September 29, 2021, 11:02pm
#8
It works! Problem was I modified variable after changing position.
Ginesis
September 29, 2021, 11:07pm
#9
I created points to an object, points are named “top_left” corresponding X=0 Y=0.
How do I write them for a position: square.X("top_left) (x axis), =square.Y(“top_left”) (y axis) ?
MrMen
September 29, 2021, 11:10pm
#10
That should work. The other way (and possibly more correct and/or backwards compatible) is to use square.PointX(“top_left”) and square.PointY(“top_left”)
Ginesis
September 29, 2021, 11:51pm
#11
both work indeed. I use square.PointX("top_left) and square.PointY("top_left)
thank you!
Ginesis
September 30, 2021, 12:18am
#12
The result, with each text modified by variables
I still have to make circles have to do… Does someone have an idea to do this?
MrMen
September 30, 2021, 12:59am
#13
Use a ShapePainter - it’ll handle circles perfectly.
Or use a sprite, if the circles are all the same size.