Help understanding center origin of even h/w of sprite

0 favourites
  • 8 posts
From the Asset Store
Create your own wss server and ws server with ssl and without ssl.
  • Hello,

    I was checking out the tutorial below and got hung up on the even vs odd pixels.

    https://www.scirra.com/tutorials/1377/h ... onstruct-2

    In the video it was mentioned to use a sprite with even width and height instead of odd because the center would be off by a pixel. I don't see how you get a center with even sides. Trying to visual this I i was checking out what C2 does. The origin appears to be in the Top Left of the pixel chosen as the origin. I guess this would actually make it the center visually since it intersects the 4 center pixels. I was under the assumption rotation occurs around the pixel itself.

    Image:

    https://drive.google.com/file/d/0B_14V9 ... sp=sharing

    Thanks for any clarity!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you can set the origin points with half measures also now! so if your picture is 17x17 your center coordinates should be X 8.5 y 8.5 ! you can calculate the center with the calculator by taking the width height of your sprite, and divide it by 2! then input the result for X Y in the origin point thing! hope it helped! not sure if i was on point! dident really understood ur question!

  • you can set the origin points with half measures also now! so if your picture is 17x17 your center coordinates should be X 8.5 y 8.5 ! you can calculate the center with the calculator by taking the width height of your sprite, and divide it by 2! then input the result for X Y in the origin point thing! hope it helped! not sure if i was on point! dident really understood ur question!

    Thanks gamecorpstudio.

    Hmm, maybe I should ask the author of the tutorial to clarify why to use divisible by 2 width and height. I didn't try .5 pixels hehe. I should just accept that it works lol. Just wish I knew why or how.

    In the tutorial the author used a 256x256 sprite and set the origin at (0,128) because of how he wants it to rotate. So, 256/2 = 128. I get that. But visually that pixel isn't in the middle. You would have to have an odd number to get a whole pixel in the middle. For example: A 3x3 sprite would look like this where [x] is the center:

    x x x

    x[x]x

    x x x

  • Yeah, you are absolutely right, but why would you want a pixel in the middle?

    The center of your 3*3 sprite would be 1.5 , 1.5

    If you would use 2 , 2 the center would be off, because it would be on the bottom-right of the middle sprite..

    The origin is a coordinate, not a pixel..

  • Oh man after reading your comment LittleStain and thinking about it for a while... it makes sense! Pixels can be subdivided. Thus, there are values in between. So, top left of a sprite is (0,0) which I was assuming is a single pixel (I was looking at the whole square). That pixel covers the values 1> x >= 0. What you said about 2,2 being the bottom right of the middle seems more clear now. I was so stuck with the idea of physical pixels like on a monitor and that something cant be smaller than the physical pixel. I am not sure If I explained myself well, but I think I understand it more.

    Thanks!

  • Don't be confuse between the distance unit "pixel" (which is a number for the computer, and like real distances, is not bound to integers) and the entity "pixel" (which is a small dot to render the screen that can be colorised), nothing smaller than a pixel will be rendered precisely sure, but your computer should do interpolations to colorise the area clearly enough (a 5x5 square can be placed at exactly a 5x5 space pixels, but it may also be slightly off, the program will then decide what to do for that, does it draw it at integer positions only, or does it renders it with smoothing on the edges, or even other things).

    The logic of your game can have half pixels, the drawing part have to compensate, it won't throw a "wtf subpixel what are you doing dude??! U crazy!" Error, it will just renders it in a certain way.

  • Aphrodite HAHA! That was a great comment. All the comments have helped to better understand what is happening. I appreciate it!

  • This however may be untrue for some displaying methods that requires integer pixels only like older game consoles, I cannot say for sure.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)