Using .XY in a Python script

For questions about using Classic.

Post » Wed Sep 01, 2010 8:19 pm

Hey everyone,

I'm new to Construct and Python so please be gentle. :P

I have a very simple question. How do I set the XY position of an object using a Python script? I can set the X and Y positions separately, but how do I set them using the XY property?

Setting the positions separately is easy:
object.X = 0
object.Y = 0

Setting them together doesn't seem to work with any of these approaches:
object.XY = {0,0}
object.XY = [0,0]
object.XY = (0,0)

What syntax should I use?

-Zumbooruk
B
2
G
2
Posts: 10
Reputation: 670

Post » Wed Sep 01, 2010 8:51 pm

Woops! I feel very silly now. I just spent more time wandering around the Wiki and found the answer. Instead of using XY, I should be using SetXY. XY is used for retrieving the X,Y position of an object and not for setting it. Yes?

I guess the Wiki left me with one question: if .X can be used to change the position of an object, what's the point of SetX?

These accomplish the same thing:

object.X = 0
object.SetX(0)
B
2
G
2
Posts: 10
Reputation: 670

Post » Wed Sep 01, 2010 9:08 pm

The more I think about this, the more it makes sense. Please disregard this thread and go about your business. :roll:
B
2
G
2
Posts: 10
Reputation: 670

Post » Wed Sep 01, 2010 9:32 pm

It's a valid question, setting and getting .xy in python is incomplete and doesn't work. You can only set and get x and y individually.

-cheers
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest