Hotspot center

0 favourites
  • 7 posts
  • How hotspots are positioned?

    It look's like their can be set only in the corner of the pixel but not in the center. Having sprite 77x77 it should be placed perfectly on the pixel center in the middle of the sprite, but it's off a bit.

    That makes object rotations wobble :/

  • I can rotate objects totally smoothly without any wobble. What browser are you using? The hotspot position should not affect wobble.

    Hotspots are set to the nearest pixel. If you can put them a fraction of a way through a pixel, it means the object is shown at a fraction-of-a-pixel offset. This can cause blurry graphics on some browsers (annoying for pixel games) or other issues like the platform movement "floating" by a fraction of a pixel above the object, because the platform movement only works by whole pixels.

    The way the math works out, when zoomed in, a pixel's position is its top left point. Consider the very top-left most pixel: you probably want the hotspot at the top left of the object's bounding box, not appearing a small way inside the object when zoomed in a long way.

    Does that help? There should be no wobble no matter where you put the hotspot, that's a different issue (or so I thought). All objects are drawn from their top-left point, so it doesn't matter where the hotspot is, it just changes the math for calculating the top-left point, and that is calculated with floating point precision.

  • I mean something like this

    If you insert new sprite, i can set hotspot in the center

    <img src="http://dl.dropbox.com/u/34375299/fanbefore.png" border="0" />

    after closing and reopening image editor it looks like this

    <img src="http://dl.dropbox.com/u/34375299/fanafter.png" border="0" />

    So as I understand it right, hotspot is placeed on the top-left corner of the pixel and can't be set to the center of the pixel?

    Send you PM with my project file.

    In my project where i have this "fan" thing, i have to to make that sprite bit different so the center point is not one pixel? <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, I see. Yeah, this seems to be something I hadn't realised about rounding the hotspot. I guess there needs to be a special override for assigning to the middle... but then that might cause the above floating point issues. Hmmmm! I'll have a think... any ideas yourself about how this should be handled?

  • Fastest and easiest would be to redraw sprites, instead of 1 pixel in the center make 4 pixels. Then you can place hotspot to the bottom-right pixel of that center - hotspot will snap to the top-left corner of that pixel.

    <img src="http://dl.dropbox.com/u/34375299/fan4.png" border="0" />

    It will then rotate smoothly, but it's difficult then to draw circular sprites, they always have one pixel in the center :/

  • Maybe I could add an option to switch off hotspot rounding?

  • Thinking about global switch or more like per instance (an option to choose in image editor)?

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