### SOLVED: Why so many different x,y possiblities? Please explain the differences?

#### infinitum3d

• Posts: 89
x
x-center
x (on screen)

How are these different? I thought the origin point (0,0) was always the top left corner. Going right, x gets larger. Going down, y gets larger.

But then for the Actor it says the origin point is "Center (Default)".  I understand the need for options but Origin Point Custom does that. Shouldn't Default be Top Left?

Anyways, that's a bit irrelevant because I understand how to use the Actor origin. Where I'm getting confused is when the Actor Origin is set to Center (Default), and I try to create a new Actor at that same point, it is never correct.

Say I have a gun 32x32. The origin at Center (Default) should be (0,0) in the center. Or is it (16,16) in the center?

When I try to create a bullet at x of gun, y of gun, where will it be created? Should I use x of gun +16, y of gun +16? or x of gun + (width of gun/2)? or should I be using x-center, y-center? or x (on screen), y (on screen)?

I've tried all these things and none of the create the bullet in the center of the gun ?!

What am I doing wrong?

Thank you so much for the help!!!

« Last Edit: May 30, 2014, 06:05:21 am by infinitum3d »

#### Photon

• Posts: 2691
x/y = top/left side of actor
x-center/y-center = center point of actor
x/y (on screen) = x/y relative to the camera (x/y of self - x/y of camera)

When you create an actor, you set its x/y. So if you set the x/y of a bullet to the x/y of the gun, you are lining up the left and top sides of the bullet and gun.

Also realize that the coordinates are based on the graphic size, not collision box size.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

#### infinitum3d

• Posts: 89

x/y (on screen) = x/y relative to the camera (x/y of self - x/y of camera)

Also realize that the coordinates are based on the graphic size, not collision box size.

Cheers! These were the two things I didn't know.  Much appreciated!

#### infinitum3d

• Posts: 89
Here's an interesting development. I have DRAWING set to show my MOUSE Y. I also have DRAWING set to show SCENE HEIGHT. And finally, I have UPDATING set to Create an actor when my mouse is clicked at Y=SCENE HEIGHT/2.

My SCENE HEIGHT is showing 480.
My actor is being created at 308, which is not 480/2 which is expected to be 240. My actor is only 2x2 so I would only expect the error to be 2 pixels at most.  I have not resized/tweened the actor.

I expect that the error is because I don't subtract the camera Y, however, the DRAWING clearing shows my mouse Y as 308 for the location of the created actor.

Any ideas?

#### Meestar

• Posts: 654
Here's an interesting development. I have DRAWING set to show my MOUSE Y. I also have DRAWING set to show SCENE HEIGHT. And finally, I have UPDATING set to Create an actor when my mouse is clicked at Y=SCENE HEIGHT/2.

My SCENE HEIGHT is showing 480.
My actor is being created at 308, which is not 480/2 which is expected to be 240. My actor is only 2x2 so I would only expect the error to be 2 pixels at most.  I have not resized/tweened the actor.

I expect that the error is because I don't subtract the camera Y, however, the DRAWING clearing shows my mouse Y as 308 for the location of the created actor.

Any ideas?

Does the camera move at all in your scene?  Because Mouse X and Y are both relative to the window, not your game scene.  I.E., if your camera is at 500 on the y-axis , your mouse would still only show 308 if you had it at 308, not 808.  Try adding y of camera to your Mouse Y value and see if that fixes things.
PM me if you require help.  I'm always glad to help out!

#### infinitum3d

• Posts: 89
No. The camera is stationary.

So I use DRAWING to display my X of mouse, and separately to display (X of mouse + X of camera) and they are both the same.

That tells me that the X of camera does not affect the "recorded" value of the  mouse coordinates.

So my problem is still that when I create an actor at (screen height/2) it is not at 240. (Or maybe it is but it's not middle of screen)
If I use (scene height/2) it is not at 240.

even though my scene height and screen height are both 240.

If I use drawing to display screen height or scene height it displays 480.
If i use drawing to display (scene height/2) it says 240 but it's not the middle of the scene.
Same with screen height. It says 240 but it's not the middle of the screen.

My actor is 2x2 pixels. My origin point is center (default).

« Last Edit: May 29, 2014, 02:49:47 pm by infinitum3d »

#### rob1221

• Posts: 9473
The best way to answer your question is to see a sample game showing the problem.

• Posts: 89

#### rob1221

• Posts: 9473
I meant a sample project (.stencyl) to find the problem.  Your game only shows that a problem exists, not the cause.

#### infinitum3d

• Posts: 89
Oh. Duh. Can I upload that here somehow or do I need something like dropbox?

#### rob1221

• Posts: 9473
You can attach the .stencyl file directly to your post.

#### infinitum3d

• Posts: 89
Ok. Took me a minute to figure out how. Here's the file.

#### rob1221

• Posts: 9473
Quote
So my problem is still that when I create an actor at (screen height/2) it is not at 240. (Or maybe it is but it's not middle of screen)
Which actor in what behavior/event?  I thought it was the fireball but the fireball is being created at x-center and y-center of the wizard and doesn't reference the screen.

#### infinitum3d

• Posts: 89
Aw heck. Yeah that's the one but I must have changed the x and y at some point today and uploaded the wrong version.  I'll try to find the right one.

#### infinitum3d

• Posts: 89
This should be the one.  You'll notice that if you set the creation coordinates of the fireball to 0,0 it is NOT the very  top left of the scene or screen.

This one has the fireball creation Y coord as sceneHeight/2 and the scene height is displayed as 480, but the fireballs are not created at the middle of the scene height.

Thank again for all your help!