change gui size bigger than game dimensions??

Started by meese72, Thu 26/05/2011 03:26:25

Previous topic - Next topic

meese72

im trying to change a gui size to bigger than my game resolution (which is 640x480) after a button is pressed on that same gui, but im getting an invalid dimensions error. If I start the game with that gui already bigger than my game dimensions i only get a warning, not an error.

How can I enlarge the gui so it doesnt give me that peskey error after pressing the button?  :'(

Khris

Well, you can't. GUIs aren't supposed to be bigger than the screen.
What are you trying to do? I'm sure there's an alternative way.

KamikazeHighland

There's probably a way to make a button to switch to another GUI.  You could have a gui that's actually a list of menus, like an RPG does.  Or have a mouseover code that shows larger text whenever you have the mouse over that button, if you have lots of small buttons.

meese72

I can always just switch to a second copy of a bigger version of that gui I guess. Its for a map. when i click on that map, it gets bigger than my game dimensions so now it can be viewed upclose and is pan-able like pdf's are when they are zoomed in bigger than the screen

Khris

I suspected something like that; it's not that complicated to work around that.

Put the full map into a DynamicSprite.
Now you can either create a copy and crop it or get the DrawingSurface and use DynamicSprite.CreateFromDrawingSurface() (which supports cropping).
Then set the resulting sprite as GUI background*.

Instead of moving the GUI, you repeat the steps above (*not this one) when the payer scrolls through the map.

monkey0506

Khris, what I think you meant was:

- Create a DynamicSprite for the GUI background with DynamicSprite.Create:

Code: ags
// top of script
DynamicSprite *mapSprite;

// show map close-up
  mapSprite = DynamicSprite.Create(System.ViewportWidth, System.ViewportHeight);
  gMap.BackgroundGrapic = mapSprite.Graphic;


- Create another DynamicSprite to crop out the needed area:

Code: ags
// show close-up, (cont'd)
  DynamicSprite *sprite = DynamicSprite.CreateFromExistingSprite(MAP_SPRITE);
  sprite.Crop(XXX, YYY, System.ViewportWidth, System.ViewportHeight);


- Get the DrawingSurface for the GUI background's sprite, and draw the cropped area onto it:

Code: ags
// show close-up (cont'd)
  DrawingSurface *surface = mapSprite.GetDrawingSurface();
  surface.DrawImage(0, 0, sprite.Graphic);
  surface.Release();
  sprite.Delete();


- While panning, repeat these last two parts, for example, in repeatedly_execute.

- When the close-up is closed, delete the sprite to free up the memory:

Code: ags
// close close-up
  gMap.BackgroundGraphic = NORMAL_GRAPHIC;
  mapSprite.Delete();


It was slightly unclear to me if that's exactly what you meant, but you'd either have to use two DynamicSprites like this (one only temporarily, then deleting it), or you would have to reassign the GUI's background graphic every loop while panning.

Khris

I was talking about using two DynamicSprites, yes. However not like you described.
Both are global. Sprite A holds the complete map, B is updated during panning to hold the zoomed, visible section.

Even if B ends up being recreated or redrawn or even being null temporarily, it should retain its .Graphic index number and when the GUI is drawn, B is already a valid sprite again. (it doesn't retain the index as I found out).

If what I suggest works and the map is static I don't even need a second sprite.

I just tested this; it does work, but I did have to set gMap.BackgroundGraphic to Map.Graphic every loop after re-creating the sprite. It's a bit dirty but does work.

So I guess it's better to tell others to do it your way. :)

monkey0506

As you learned the Graphic is relative to the object being pointed to and not the pointer itself, so if you're creating a new sprite with any of the Create functions, there's a chance it will have a new sprite number (Graphic). If you delete a dynamic sprite then IIRC that slot becomes available for new sprites, but if you're using more than one dynamic sprite in your game then it's simply not viable to rely on a Graphic slot being unchanged when creating a new sprite, even if deleting the old one first.

The DrawingSurface functions allow you to change the existing DynamicSprite without changing its Graphic number.

Of course you know that, I just wanted to elaborate for any readers that didn't. ;)

meese72

Since im so new to all this is it simpler for me to just create 2 versions of my map? i mean one GUI version that is small (200x200) and the other version of the map is a Gui bigger than my game dimensions (map is 1800x1800) that i can just move around with the mouse? ill still get a warning that the gui is too big at gaem start, but alteast i dont have to do all that drawing stuff (omg im afraid of trying that, lol!)

So guys, is it ok if i do just the 'simpler' way, or is it really a bad idea and i just suck it up and try dynamic drawing....eeeek?

monkey0506

Unless I'm mistaken, that "warning" about the GUI being larger than the screen resolution is fatal. By that I mean that I'm pretty sure you can't "just create..a GUI bigger than [your] game dimensions".

A GUI larger than the screen resolution doesn't make sense. A Graphical User Interface that the user can't graphically interface with because it extends outside the boundaries of the screen is illogical. That's why AGS doesn't allow it.

If you want this feature in your game, suck it up and do the dynamic drawing route. Don't try it. Just do it.

Don't be afraid to try something. Just because it might not work your first time around doesn't mean you should avoid it altogether. IF you get an error, or errors, or if it runs fine but just doesn't work exactly how you want, then let us know. That's what we're here for. Users like Khris and myself put a lot of time into helping others learn how to use AGS, but we can't help you learn something you won't even attempt because you're "afraid lol".

It's not even a complicated concept, and I've already pretty much broken it down for you step-by-step. If you need more help above and beyond that, tell us what you've already tried, and what your results were.


SMF spam blocked by CleanTalk