import frames by alpha clipping

This forum is currently in read-only mode.
From the Asset Store
three fully animated characters ideal for your RPG side scroller projects
  • one feature that i think would be really useful is import frames of a spritesheet by alpha-clipping it. In my opinion this is much more powerful than the default grid clipping method. There's a 2d game engine(clanlib) that uses this method so i thought it would be great to have it on construct.

  • What is alpha clipping and how does it work?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Basically it's selecting certain parts of an image in a sprite sheet, based on whether or not that particular part of the image is surrounded by transparent, or the selected mask color's pixels.

    I'd say the pitfalls for that kind of function should be obvious.

  • You mean the color mask?

  • No. More like magic pink.

    http://en.wikipedia.org/wiki/Chroma_key

  • yeah i know there's some restrictions when using this method. I've read the code that does this. it basically receives a png file , x, y and alpha limit by parameter. It then stores all pixel data in a matrix, reads it pixel by pixel beginning on position x,y , left from right , top to bottom, tests alpha value of pixel , if greater than alpha it marks it as opaque. In the end it returns all rects corresponding to the sprites in the spritesheet. How exactly the algorithm works i couldn't understand

    one implication of this algorithm is that all sprites must be alligned by Y. example:

    <img src="http://dl.getdropbox.com/u/2472278/spsheet.png">

    it would get the purple square first, not the blue one as it is expected, cause it is above the others

  • search and flood fill limited by alpha, then find bounds and clip.

    Simple but slow. Could be sorted by bounding box center.

    Should include a minimum bounding box size.

    Issues could occur if sprites overlap each others bounding boxes, which is a rare case I'd say.

  • there's an alternative that i think uses a similar method but maybe would be more efficient, the technique used on http://bit.ly/49np5J . You select the sprite in the spritesheet and it then shrinks the boundary to cover exactly the sprite frame. Then it exports the animation coordinates "map" as XML like <Frame1>rect(x,y,w,h) etc... Though you have yet to adjust the offset sometimes... I'd like to have the source code of this program :

  • All of which can be accomplished with a decent image editor. So unless there's another function to crop said sheets at runtime, this is all pointless.... imho. Its just another proverbial easy button, best suited for something like Stencyl.

  • That Sprite Buddy looks quite useful. If it can export one file per frame we'd be set.

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