Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Centre point of a region entity?  (Read 2445 times)

0 Members and 1 Guest are viewing this topic.

redfox

  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 122
    • View Profile
Centre point of a region entity?
« on: July 05, 2010, 06:45:12 PM »

Can anybody tell me a simple way to get the centre point of a region entity on screen?  I can get the X and Y of the bottom right corner, but I am trying to calculate the middle, and the same script is used on multiple regions of different size and position.

Perhaps if I could get Width and Height of a region entity?

Many Thanks  :)
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Centre point of a region entity?
« Reply #1 on: July 05, 2010, 08:52:48 PM »

Hi there. :)

What I would do is to get all region entity points and tried to approximate somehow the middle point.
You can get your points like this (untested but should work)

Code: WME Script
  1.  
  2. var ent = Scene.GetNode("yourNode");
  3. var region = ent.Region;
  4.  
  5. for (var x=0; x<region.NumPoints;x=x+1)
  6. {
  7.       var point = region.GetPoint(x);
  8.       Game.Msg(point.X + " : " + point.Y);
  9. }
  10.  
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet
 

Page created in 0.041 seconds with 21 queries.