Jump to content


Photo

Getting an object's x/y screen pos.


  • Please log in to reply
10 replies to this topic

#1 Mr Weird Guy

Mr Weird Guy

    GMC Member

  • New Member
  • 69 posts

Posted 04 June 2011 - 10:01 PM

I probably asked this question a year or two ago, but I forgot the answer. How would I calcuate an object's X or Y position on the screen rather than in the entire room? I'm just totally drawing a blank on this here. :V
  • 0

#2 Davve

Davve

    Procrastinator

  • GMC Member
  • 3665 posts
  • Version:GM8.1

Posted 04 June 2011 - 10:05 PM

If you by "screen" mean the window:
object.x-window_get_x(),object.y-window_get_y()

Or if you by "screen" mean the view:
object.x-view_xview,object.y-view_yview
  • 0

#3 Mr Weird Guy

Mr Weird Guy

    GMC Member

  • New Member
  • 69 posts

Posted 04 June 2011 - 10:29 PM

Yeah, I guess I do mean the view. That code works, I just gotta figure out how to actually make it work correctly for what I'm doing. Man, screen transitions are annoying. :|
  • 0

#4 theepicgeno

theepicgeno

    We Are Epic

  • GMC Member
  • 520 posts
  • Version:GM8.1

Posted 28 February 2012 - 08:46 PM

this will probably help me!
  • 0

#5 gardian20

gardian20

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 28 February 2012 - 09:35 PM

how do you get on-view coordinates of non-objects? like to draw something

Edited by gardian20, 28 February 2012 - 09:36 PM.

  • 0

#6 theepicgeno

theepicgeno

    We Are Epic

  • GMC Member
  • 520 posts
  • Version:GM8.1

Posted 28 February 2012 - 10:30 PM

how do you get on-view coordinates of non-objects? like to draw something

Maybe you would draw the room height and width. Like this:

draw_text(x,x,""+room_height+" and "+room_width)

is that even what you mean?
  • 0

#7 gardian20

gardian20

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 28 February 2012 - 10:48 PM


how do you get on-view coordinates of non-objects? like to draw something

Maybe you would draw the room height and width. Like this:

draw_text(x,x,""+room_height+" and "+room_width)

is that even what you mean?

wait........i wanted it to draw something on the view as it moves. i do not quite under stand what you mean.....but i am not sure it is what i am looking for
  • 0

#8 theepicgeno

theepicgeno

    We Are Epic

  • GMC Member
  • 520 posts
  • Version:GM8.1

Posted 28 February 2012 - 11:06 PM



how do you get on-view coordinates of non-objects? like to draw something

Maybe you would draw the room height and width. Like this:

draw_text(x,x,""+room_height+" and "+room_width)

is that even what you mean?

wait........i wanted it to draw something on the view as it moves. i do not quite under stand what you mean.....but i am not sure it is what i am looking for


I read that you wanted to draw the room height and width. Can you upload your .gm* so i can see?
  • 0

#9 gardian20

gardian20

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 28 February 2012 - 11:20 PM




how do you get on-view coordinates of non-objects? like to draw something

Maybe you would draw the room height and width. Like this:

draw_text(x,x,""+room_height+" and "+room_width)

is that even what you mean?

wait........i wanted it to draw something on the view as it moves. i do not quite under stand what you mean.....but i am not sure it is what i am looking for


I read that you wanted to draw the room height and width. Can you upload your .gm* so i can see?

how do i do that? anyway, if i do this, would i come out with something drawn on a coordinate that is compared to the view not to the whole room?
  • 0

#10 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9260 posts
  • Version:Unknown

Posted 29 February 2012 - 04:42 AM

how do you get on-view coordinates of non-objects? like to draw something

view_xview[n] and view_yview[n] return the (x, y) coordinates of the top-left corner of the n'th view. So just offset your coordinates from there. For example, if you want something to stay at (10, 10) from the view 0 position instead of the room, you'd draw/place it at (view_xview[0]+10, view_yview[0]+10). Make sense?

-IMP
  • 0

#11 gardian20

gardian20

    GMC Member

  • GMC Member
  • 99 posts
  • Version:GM:Studio

Posted 29 February 2012 - 01:08 PM

yes, let me go try it.......




EDIT: It works perfectly!!!!! thanks!

Edited by gardian20, 29 February 2012 - 01:26 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users