# Get absolute from relative?

This forum is currently in read-only mode.
0 Favourites
• 4 posts
• Ok math question again.

Im working with a distort map's get sprite vertexX, and vertexY (Sprite.VertexXY(Column, Row)), but that only returns a relative value from the sprites (I'm guessing) size, IE distort sprite absolute at column 0, row 0 to sprite x +0= 0, and distort sprite absolute at column 0, row 0 to sprite x +sprite width= 1, width x 2 would be 2 etc.

So my question is, is there any way to get the real world or absolute x from that?

• yes theres a way, but you need to find out if its the offset from a specific points original position or from the sprites center

if its an offset from that specific points original location your going to need to figure that out then add the xy offsets.

so lets say you distort object is a 64x64 square, with a distort map of 2,1 (3x2)

first your going to need to know which X(column),Y(row) your using, then your going to need to find out the top left corner's xy location(of the square, non distorted of course). its important that you keep track of the distort map column/row size and keep it in 0 based form, and keep its angle and width/height at the original objects values or else it might not work unless you implement something to get around that in the upcoming formula.

so now that you have those things, you need to actually put all that info into a formula that'll do what you intend.

so

for X:

sprite.left+((sprite.width/sprite('distortmapColumns'))*{current column})+Sprite.VertexX({current column},{current row})

for y:

sprite.top+((sprite.height/sprite('distortmapRows'))*{current Row})+Sprite.VertexY({current column},{current row})

and im pretty sure that'll work.

if im completely out of the ball park its because the assumptions i made were wrong (i dont have a comp to test if i understand the elements of the problem correctly)

• ## Try Construct 3

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

Construct 3 users don't see these ads
• Alright will test that out, thanks.

I am curious as to why get vertexX is giving width tho...

I mean I was hoping it would at least give relative pixel coords.

• Ehh I think for my purposes I may just go with a dummy to get the world x,y.

Your equation may work with some tinkering, but I think I would have to add a pv to keep track of a "virtual" column/ row for "sprite('distortmapColumns')".

Im guessing what I would need to do is split up the display (displaywidth/(spritewidth/map columns)), and keep track of where that would be in the pv.

The cap shows kinda what I was hoping vertexX did.

http://dl.dropbox.com/u/666516/getvertexabsolute.cap