Problems with changing sprites

Started by Jakerpot, Fri 09/01/2009 05:46:08

Previous topic - Next topic

Jakerpot

Hi! Well, i know that i'm creating too much topics, but i cant figure out this 2 things:

1- how can i change the GUI button sprite when some animation is rolling or an action ocurring, so the player cant use the buttons. It auto put some pixels in the GUI to show that the player cant use it. I have the graphics, but dont know how to change it.

2-How can i turn the inventory invisible when pick up a item from it? Like, when you pick up the item in the slot (my inventory is a window that pop up when clicked on a button) how can i turn the visibility of the inventory off auto. So i dont need to pick the item, press Ok and then use it. This can be seen in many games.

Thanks, and for no more topics, can i edit this post w further questions, so when i have a new one i dont need to star a new one?
Thanks again. J-



Ghost

#1
1: Buttons can have up to three sprites, and you can set them with
button.NormalGraphic
button.MouseOverGraphic
and
button.PushedGraphic
Just take care that, if you alter the normal graphic, you should reset it at some point so that the player can see the button's "free" again.

Buttons can also display an animated view with
button.animate

Much of what you need to know is covered in the manual. It helps to know that in AGS, basically, all commands are part of the thing they relate to, so reading up all the commands belonging to a CHARACTER will give you a good idea what is possible there.


Trent R

As for the grey pixels popping up over your buttons, that's set under the General Settings. Look for "When player interface is disabled, GUIs should" and change that to whatever works for you.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

As for part 2, this should solve it:
Code: ags
// inside repeatedly_execute, GlobalScript.asc
  if (player.ActiveInventory != null && gInventory.Visible) gInventory.Visible = false;

You might have to turn gInventory's visibility mode from "Popup modal" to "Normal, initially off".

Jakerpot

#4
Ok guys, thanks, but khris, when i useyour command, when testing, i pick the object and the inventory turns off. Ok, but then i cant open it up clicking on the inventory button again! I think this is because, if i click the right button a few times on mouse, the inventory item will be there as a cursor. Cant i make a code that will block the item to use as a cursor less then i select it on inventory?
Ifyou dont get it:
i click on the inv item icon. ok. than i am using it. but when i change the mouse icon, if i press R button on mouse, the iten will be there! Cant i block this inv item from appearing there? And how can i open the inventory again, after clicking on the object?
Thanks J-
EDIT: Oh damn. Maybe Chris Jones should put a button.BlockedGraphic command on AGS v3.2.  ;D

Another question: Why this script doesnt works? When i try to run the game, it says:

GlobalScript.asc(18): Error (line 18): Parse error in expr near 'mouse'

Code: ags

if (mouse.x, mouse.y == btnOptions){ 
 btnOptions.Animate(VOPTIONS, 1, 1, eRepeat);
 }


i put it into repeatdly execute, trying to animate a button when mouse is over it. Help Please!




Trent R

#5
To make Khris's work, put this into your inventory button's code. (Before you actually show the gui)
Code: ags
player.ActiveInventory=null;
//Show gInventory here



As for the right clicking thing, that's a default thing in Sierra games, and therefore is in the default template. You'll want to check out the on_mouse_click code in the global script (also look at the mouse wheel, cause that does a similar thing).


Instead of a BlockedGraphic, put another line into repeatedly_execute (or maybe repeatedly_execute_always)
Code: ags
if (IsInterfaceEnabled()) {
//Set Normal Graphics here, you could create another function and call it here
}
else {
//Set Blocked Graphics here, you could create another function and call it here
}

Like I said, I'd probably create another function (probably will a bool parameter) and call it within those, then you don't have to type the same lines over and over.


As for your errored script, I believe it's because there's a comma and also because you're comparing ints to a button. Try using the && (logical AND) operator and also putting the bounds of btnOptions in there.

[Edit]: See Khris's post below. :)



~Trent
PS-That last line may not have made sense. Sorry.
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

After you use the item, doesn't it get removed from the player's inventory? Alternatively, you can call "player.ActiveInventory = null;" to remove it from the available cursor modes.

Regarding animating the button:
It won't work like that. You can only compare e.g. two ints, or two objects, not arbitrarily seperated int coordinates with a GUIObject.
You need to do:
Code: ags
 if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == btnOptions) {
    ...


If you put it in rep_ex, the command to Animate the button will be called 40 times a second, resulting in a flickering, if anything at all.
Unfortunately, there's no GUIButton.Animating property yet. I'm at work and can't provide a solution right now, sorry.

Jakerpot




SMF spam blocked by CleanTalk