ga icon indicating copy to clipboard operation
ga copied to clipboard

Button click area problems

Open indra-uolles opened this issue 8 years ago • 2 comments

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 avatar Sep 19 '17 19:09 indra-uolles

The problem was in

g.scaleToWindow();

I commented it and click area was fixed.

indra-uolles avatar Sep 20 '17 18:09 indra-uolles

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

cdrch avatar Jul 31 '21 00:07 cdrch