kittykatattack / ga

The world's tiniest, cutest and funnest game engine
453 stars 85 forks source link

Button click area problems #65

Open indra-uolles opened 7 years ago

indra-uolles commented 7 years ago

I'm making a splash screen. It has a background image and a button on it. Background image is jpg (1200x520) and button image is png (105x75). Code looks like this:

splash = g.group();

bg = g.sprite("background.jpg");
bg.x = 0;
bg.y = 0;
splash.addChild(bg);

var buttonFrames = g.frames(
    "assets/images/howtobtn2.png",
    [[0,0],[0,50],[0,75]],
    105, 25
  );

howtoBtn = g.button(buttonFrames);
howtoBtn.x = 100;
howtoBtn.y = 207;

splash.addChild(howtoBtn);

howtoBtn.release = function(){
  g.state = howto;
};

I don't understand why click area (where pointer appears) is above the button image, not right over it. If I don't assert howtoBtn coordinates then click area position is ok.

indra-uolles commented 7 years ago

The problem was in

g.scaleToWindow();

I commented it and click area was fixed.

cdrch commented 3 years ago

@indra-uolles PR #80 should fix this issue without a need to remove screen scaling. 😃