overlap a sprite on another sprite sync

White Dragon

New member
I've write a func to overlap a part of a sprite on the original sprite to simulate a puddle (for ex.).
This is the func:
Code:
int draw_clipping(void self, float clipx, float clipy, int color) {
    if ( openborvariant("in_level") ) {
        void spr = getentityproperty(self, "sprite");
        float x = getentityproperty(self, "x");
        float z = getentityproperty(self, "z");
        float a = getentityproperty(self, "a");
        int facing = getentityproperty(self, "direction");
        int layer = getentityproperty(self, "setlayer")+2;
        float xpos = openborvariant("xpos");
        float ypos = openborvariant("ypos");
        float xshift;

        if ( spr != NULL() ) {
            if (facing == 1) facing = 0;
            else facing = 1;

            //drawstring( 10,190,0,"Var (): "+trunc(xpos));
            changedrawmethod(NULL(), "tintmode", 1);
            changedrawmethod(NULL(), "tintcolor", color);

            //changedrawmethod(NULL(), "clip", 10, 20);
            changedrawmethod(NULL(), "cliph", 356);
            changedrawmethod(NULL(), "clipw", 256);
            changedrawmethod(NULL(), "clipx", x-xpos-clipx);
            changedrawmethod(NULL(), "clipy", z-a-ypos-4-clipy);

            setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, 6, -1);

            drawsprite(spr, x-xpos, z-a-ypos-4, z+2, layer);

            changedrawmethod(NULL(), "enabled", 1);
            changedrawmethod(NULL(), "reset", 1);
            setdrawmethod(NULL(), 0);
        }

    }
}

Then calling this func by this way: draw_clipping(self, 70, 15, 0xFF8000) I can draw a clipped sprite to show the lower part of the sprite of cyan color for ex.

But when the character walks the clipped sprite is shifted of 1 pixel (unsync) in x coord.
I'v tried to execute this func on event ondraw or updatescript or script but the problem is the same!  :'(
Is there a good solution?
 
Back
Top Bottom