How to center Interactive Object

Hello, newbie here.

I’m making a card game , I just thought it would be an easy entry point into heaps. My card class
Is made up of an object , a bitmap and an interactive object, implementing the drag and drop was really easy but I have just one problem,
The card is not centered.

I tried to center the tile and then move the interactive by “-0.5 * tile.size” but it just makes ¼ of the tile selectable.

So is there a way to change the anchor point of an interactive, if no I’m still open for any suggestions, thank you.

A very short code sample of some few lines would be nice to correctly frame the issue described here.

But I guess you have to do some calculating by hand/code.

import h2d.Interactive;
import h2d.Bitmap;

class Iroro extends hxd.App {

        static function main() {
                new Iroro();
        }

        var bmp : Bitmap;
        var ia : Interactive;
        

        override function init() {
                bmp = new Bitmap( h2d.Tile.fromColor(0xFF, 80, 128), s2d );
                ia = new Interactive( 80, 128, bmp );
        }

        override function update(dt:Float) {
                if(hxd.Key.isDown(hxd.Key.MOUSE_LEFT))
                        bmp.setPosition( s2d.mouseX-(ia.width/2), s2d.mouseY-(ia.height/2) ); // by "hand/code"
        }
}

Maybe h2d.Interactive needs a new feature at some point, regarding this…

1 Like

That was really helpful, thank you.
Moving the bitmap instead of the interactive just works.
Thanks

1 Like