0 Favourites

# Can someone Explain Touch.X vs Touch.XAt()

• 6 posts
• I seemingly have a basic understanding of it. I read it in the manual, but I am not 100% sure.

I don't want to accidentally confuse someone else learning about it too.

I understand

Touch.XAt(0),Touch.YAt(0)

is getting the location of a touch, what is the At(0) part?

Would

Touch.X,Touch.Y

Do the same?

or would it be Touch.X(0), Touch.Y(0)?

Is Touch.XAt(0) needed in order to get X of two Touches?

https://www.scirra.com/manual/119/touch

• yes, as you read there, Touch plugin supports multiple touches... the touch.XAt(0) is the id of the first finger on screen or touch detected... then 1,2 ,3 are other touches in same time... usually used for zoom in and stuff like that however i never had a need to use it. most game dont require multiple touches. you can work around it with visuals.

any captain here to explain this better?

• I seemingly have a basic understanding of it. I read it in the manual, but I am not 100% sure.

I don't want to accidentally confuse someone else learning about it too.

I understand

Touch.XAt(0),Touch.YAt(0)

is getting the location of a touch, what is the At(0) part?

Would

Touch.X,Touch.Y

Do the same?

or would it be Touch.X(0), Touch.Y(0)?

Is Touch.XAt(0) needed in order to get X of two Touches?

https://www.scirra.com/manual/119/touch

You are looking at the values if you want to use Absolute X and Y for coordinates.

In most cases that is not needed and touch.X and touch.Y gives you the coordinates for the position of the touch on the screen based on 0,0 being top left corner of your layout.

If you are using different layers with different size layouts or transferring coordinates between layouts or using multiple touches then using Absolute also allows you to specify which layer and on what touch the command is used.

• I was mostly confused on what At( ) meant in XAt( ).

The Manual refereed to "At" Expression as Absolute and I didn't realize "At" meant Absolute.

I looked it up on the Touch Page of the Manual because of Lamar.

It makes me assume Touch.X would be relative if a layer was rotated, I didn't even think of that possibility until then.

I was only familiar with Abs() as Absolute.

Abs() of course makes any value positive.

abs( 5 - 10) will return 5 instead of -5

-Abs() will make any value negative.

-abs( 10 - 5) will return -5 instead of 5

It is used to keep any math in the abs() expression to always have positive or negative results.

These are of course different Absolutes, just tossing it in to help some readers.

I only tried to find/search for "XAt".

I thought trying to search for At would have been difficult, since it is a common word.

I missed the quote below, because it was under AbsoluteX in the manual.

"The At expressions can return the absolute position of any touch given its zero-based index, and the ForID expressions return the position of a touch with a specific ID."

Some Examples for the above Quote:

XAt(index)

XAt(index, "layer")

XForID(index)

XForID(id, "layer")

After finding Absolute in the Manual, I read the At expression returned the Absolute position.

I then noticed this.

AbsoluteXAt(index)

What is the need for Absolute if At expression does Absolute?

Does AbsoluteX do the same as XAt?

• lamar

I was mostly confused on what At( ) meant in XAt( ).

The Manual refereed to "At" Expression as Absolute and I didn't realize "At" meant Absolute.

I looked it up on the Touch Page of the Manual because of Lamar.

It makes me assume Touch.X would be relative if a layer was rotated, I didn't even think of that possibility until then.

I was only familiar with Abs() as Absolute.

Abs() of course makes any value positive.

abs( 5 - 10) will return 5 instead of -5

-Abs() will make any value negative.

-abs( 10 - 5) will return -5 instead of 5

It is used to keep any math in the abs() expression to always have positive or negative results.

These are of course different Absolutes, just tossing it in to help some readers.

I only tried to find/search for "XAt".

I thought trying to search for At would have been difficult, since it is a common word.

I missed the quote below, because it was under AbsoluteX in the manual.

"The At expressions can return the absolute position of any touch given its zero-based index, and the ForID expressions return the position of a touch with a specific ID."

Some Examples for the above Quote:

XAt(index)

XAt(index, "layer")

XForID(index)

XForID(id, "layer")

After finding Absolute in the Manual, I read the At expression returned the Absolute position.

I then noticed this.

AbsoluteXAt(index)

What is the need for Absolute if At expression does Absolute?

Does AbsoluteX do the same as XAt?

Absolutes in touch can be used for drawing lines and creating shapes which is I think it's primary purpose. I haven't found any use for it but other people might.

• ## Buy Construct 3

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

Construct 3 users don't see these ads
• Touch.AbsoluteX is the same as Touch.AbsoluteXAt(0).

Touch.AbsoluteX just does not take an index as parameter, and is always about index zero. (index in the list of touches)

Since 'Absolute' (in this case) means position on the canvas, with x=zero and y=zero at left-up your SCREEN, it can not take the "layer" as parameter.

TouchID is an expression (a number) that identificates roughly a 'gesture'.

If you use 'on any touch', that expression holds a number corresponding with all the touches that are on that moment on screen. So, everywhere you see 'id' like in 'Touch.AbsoluteYForID(ID)' .... that ID is a number retrieved and stored with the TouchID expression.

I think that most people get the x/y coordinates from a HUD layer with no parallax when they want absolute x/y coordinates. After all thats kinda the same.

Now, wherever you see 'Get ..... coordinate in the layout (with x=zero and y=zero at the zero points in the layout) you can specify a "layer" in the parameters. And this absolutely necessary.

Consider this example:

https://www.dropbox.com/s/bxnfx9snt60j9 ... .capx?dl=0

I have a rotating layer with parallax. When i fire bullets at touch.x,touch.y (layout coordinates) ... then the bullets are not going direction the touch position. That is because the layer with the turrets is (with its own coordinates) moving inside the layout.

To fix this, we need the layout parameter.

https://www.dropbox.com/s/gn013jr7lwvki ... .capx?dl=0

Surely hope i helped you some.

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