Rotating sprites while keeping resolution consistent?

  • Hello again.

    So I have a game that is 240x160, rescaled to 960x640. I would think this means that everything is pixelated, but I'm noticing when you rotate sprites they are not sticking to the expected resolution.

    (Notice how the rotated arm and gun are at a high resolution)

    Is there any way to stop this from happening?


  • administrators

    This is the expected behavior (different from how the Flash target used to work, but it's always worked this way on native.) But actually I juuust added something to handle this on the dev branch.

    In your project.xml you need <set name="hxp_extras"/>, and then call haxepunk.pixel.PixelArtScaler.globalActivate();. This will cause your game to be rendered at the lower resolution of HXP.width x HXP.height, then scaled up in a way to minimize blurring in case the window resolution isn't a perfect multiple.

    Take a look at my port of Matt Tuttle's Spelunk for an example. Note that you'll need to install HaxePunk from git to get this to work.

  • administrators

    One more thing, on the Git version you can also set Graphic.smoothDefault = false and Graphic.pixelSnappingDefault = true to make sure things at non-integer positions don't blur. globalActivate does this for you, just make sure you call it prior to creating any Graphics so that the default applies.

  • so PixelArtScaler.globalActivate does the job, but now the camera is all shaky when i move around. is there something I can do on my end to prevent that?

  • administrators

    Help me understand what you mean by shaky. I've noticed when using fixed time step it can appear shaky when there are dropped frames, and lowering the resolution makes this appear worse.

  • The player was shaky when the camera was moving--looking like they were having trouble finding the right pixel to snap to. Being more careful to make sure the camera's values were integers got rid of the issue.

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.