Author Topic: Scrolling in Pause Menu  (Read 1134 times)

superbany

  • Member
  • **
  • Posts: 53
  • Karma: +0/-0
  • [Please enter text here]
    • View Profile
    • Superbany's games
Scrolling in Pause Menu
« on: Mon, Apr 16, 2012 »
I've been trying to get a working pause menu going for a while now. I started with the default, and have tried replacing bits of it at a time. However, I'm having trouble getting any buttons in the menu to scroll properly with the map, currently with only an unpause button. Here's the code:
Code: [Select]
public function PauseMenu()
{
super();
FlxG.mouse.show();
scrollFactor.x = scrollFactor.y = 0;
var w:uint = 80;
var h:uint = 92;
x = (FlxG.width-w)/2;
y = (FlxG.height - h) / 2;

bgdSprite = new FlxSprite(0, 0, ImgBgd);
bgdSprite.alpha = .8;
add(bgdSprite, true);
add((new FlxText(0, 0, w, "PAUSED")).setFormat(null, 16, 0xffffff, "center"), true);

continueButton = new FlxButton(4, 31, unpause);
continueButton.loadGraphic(new FlxSprite(0, 0, ImgContinueButton), new FlxSprite(0, 0, ImgContinueButtonPressed));
add(continueButton, true);

add(new FlxSprite(4,50,ImgTestSprite), true);
}

The background, header text, and TestSprite all show properly, but the graphics for the Continue button do not scroll with the map. The button can be clicked where it should be at and works (currently only traces "unpausing..."), but the graphics are usually not visible, unless the player moves so the screen scrolls to the upper left corner of the map.
Any hints on how to get the graphics to scroll with everything else would be much appreciated. Thanks!

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Scrolling in Pause Menu
« Reply #1 on: Mon, Apr 16, 2012 »
I didn't understand your problem. Do you want a normal pause menu? If yes, what does it have to do with scrolling? Or do you want your game to be alive in the background when you show the pause menu?
blog, twitter, Check out my award winning game, Rot Gut:

superbany

  • Member
  • **
  • Posts: 53
  • Karma: +0/-0
  • [Please enter text here]
    • View Profile
    • Superbany's games
Re: Scrolling in Pause Menu
« Reply #2 on: Mon, Apr 16, 2012 »
I want to have a simple pause menu, with buttons for volume control, returning to main menu, etc., not having the game continuing in the background.
Its just that the graphics for any buttons that I put in end up scrolling with the level and staying in the top left corner of the map, instead of remaining in fixed positions on the screen. So, pressing p to pause when the character is at the top of the map will cause the pause menu to work fine, but pausing anywhere else causes the image for the button to be displaced, or even off the screen, even though it is clickable at where it should be located.

Player located at top left of map:


Player moved right so the screen scrolls slightly over:

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Scrolling in Pause Menu
« Reply #3 on: Mon, Apr 16, 2012 »
did you set it's scrollfactor to new flxpoint(0,0)?

I reckon you have all your pause menu in a Flxgroup, if so, call setAll("scrollFactor", new FlxPoint(0, 0)); on them after you create it.

BTW, I LOVE your character, he's cute that I want to bite the monitor! Not feeling the same about the art, except water.
blog, twitter, Check out my award winning game, Rot Gut:

superbany

  • Member
  • **
  • Posts: 53
  • Karma: +0/-0
  • [Please enter text here]
    • View Profile
    • Superbany's games
Re: Scrolling in Pause Menu
« Reply #4 on: Tue, Apr 17, 2012 »
I'm actually using an older version of flixel (don't want to change midproject), so FlxGroup don't have a setAll to use.  :-\ But the button's scrollfactor is set to 0.

However, would it work to have, instead of:
Code: [Select]
continueButton.loadGraphic(new FlxSprite(0, 0, ImgContinueButton), new FlxSprite(0, 0, ImgContinueButtonPressed));to have:
Code: [Select]
continueButtonSprite=new FlxSprite(0,0,ImgContinueButton);
continueButtonPressedSprite=new FlxSprite(0,0,ImgContinueButtonPressed);
continueButton.loadGraphic(continueButtonSprite,continueButtonPressedSprite);

and then, whenever the game is paused, reset the locations of <continueButtonSprite> and <continueButtonPressedSprite> to match the screen location?



Oh, thanks. The art still isn't totally done yet.

test84

  • Key Contributor
  • *****
  • Posts: 1328
  • Karma: +0/-0
  • ت
    • View Profile
    • My personal site.
Re: Scrolling in Pause Menu
« Reply #5 on: Tue, Apr 17, 2012 »
I think just setting scrollFactor to zero would do the job. Isn't it the case that you do with rest of the menu that apparently is working fine?
blog, twitter, Check out my award winning game, Rot Gut: