how can I know what's the coordinate of screen center ?

jasonshowjasonshow Member Posts: 71
edited November -1 in Working with GS (Mac)
my player is running,and screen always go right,
how can I know what's the coordinate of screen center ?
thanks.

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    (0,0) is the bottom left corner of the scene.

    So if your scene is 480x320 center would be (240,160)

    That what your wanting to know?
  • jasonshowjasonshow Member Posts: 71
    yes,I know that.

    but my screen is bigger than 480x320,(maybe 100000x320)
    and I make it auto scroll to right.
    so, how can I know what's the coordinate of screen center?
    thanks.
  • cbtcbt Member Posts: 644
    On the actor you are using to control the camera;

    Display Text:
    Self.X
    Self.Y

    And make sure to make the "camera area" as tiny as possible on the editor.
  • dunkelgeistdunkelgeist Member Posts: 68
    You need to access your Scene attributes for that.

    So it may be like this:
    1. Make a new actor, let's say centerSearcher
    2. Put it on your Scene
    3. Double-Click the Scene actor NOT THE PROTOTYPE and click the locker to acces its behaviors.
    4. Now you can access Scene attributes from there and pass them to Game attributes if needed.
  • jasonshowjasonshow Member Posts: 71
    cbt,your method works, but because of actor's hieght,so, there's a little floating.

    dunkelgeist,seems good, but what's attribute of scene that I realy need ?
    thanks.
  • dunkelgeistdunkelgeist Member Posts: 68
    CurrentScene.Size.Width / 2
    CurrentScene.Size.Height / 2

    Will give you the coordinates you need for X and Y ;-)

    That is if you need the permanent true center of your Scene, otherwise, if you want to have the center of the visible area I'll probably stick with cbt method but adding an additional actor constrained in position to the camera, so you can set any size you want.
  • jasonshowjasonshow Member Posts: 71
    dunkelgeist,
    it will get the whole scene's center,
    but I need is this screen's center.
    (the screen is scrolling to right)
  • dunkelgeistdunkelgeist Member Posts: 68
    I've edited my previous post, sorry for the misunderstood.
  • dunkelgeistdunkelgeist Member Posts: 68
    Maybe you can even play with Camera.Origin and Camera.Size to get the point, I don't really know how Camera.Origin works and I'm on a pc without GameSalad right now to test it but maybe...

    If Camera.Origin.X and Y mark the camera center you're good to go.

    If they mark the bottom-left corner then you could do something like:
    Camera.Origin.X + Camera.Size.Width/2
    Camera.Origin.Y + Camera.Size.Height/2

    Again, just guessing, but hope it helps.
  • jasonshowjasonshow Member Posts: 71
    thanks dunkelgeist,
    it works!
Sign In or Register to comment.