Hello!
Im totally new on scripting in 2.7 and am in need of help.
This is the problem: I am trying to get a gui button, Optionsbutton, in the upper gui menu to animate when the mousecursor is over it. The button needs a view for animating and thats where the problem is. I can get the button to animate either way and there doesn't seem to be a way to script it easily like using MouseOverGui.
Any help will be appreciated, this may be very simple.
Thanks!
/A-Hed
Try putting the following script in the repeatedly_execute global function:
Button *btnOptions ----> your GUI button to animate
at the top of the global script:
int btnOptions_normalGraph = XXX; // must specify it here to restore after animation
bool btnOptions_isAnimating = false;
int view = XXX;
int loop = XXX;
int delay = XXX;
repeatedly execute:
if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == btnOptions)
{
if (btnOptions_isAnimating == false)
{
btnOptions.Animate(view, loop, delay, eRepeat);
btnOptions_isAnimating = true;
}
}
else
{
if (btnOptions_isAnimating == true)
{
btnOptions.NormalGraphic = btnOptions_normalGraph;
btnOptions_isAnimating = false;
}
}
Thank you very much for the reply, I would have never thought of it to be that much scripting!
When I have copied this into the global script and am about to test the game it says, under the repeatedly execute, that isAnimating is an undefined symbol. I think that is quite strange because the isAnimating seems to work fine on the first part of the script.
If anyone has got a reason for why this is happening I would appreciate it very much!
Thanks!
/A-hed
Did you change btnOptions_isAnimating to isAnimating?
It must match the one that's used in repeatedly_execute.
[edit]
So make sure that the name that's declared at the top of the main global script is *exactly* the same as that used inside the repeatedly_execute function.
This is very strange, by looking at your scripting I can understand how it's supposed to work but when I test the game it's doing something completely different!
When I hold the mousecursor over the Guibutton it changes to the Guibuttons MouseOver image (to the image I used to have) and when I hold the mousecursor besides the Guibutton it animates as it should do. So when I hold the mouse over the button it changes to the mouseover image, when I'm not it animates correctly.
I tried changing some isAnimating from false to true and vice versa, it didn't help though so I changed them back.
Thanks for the replies, hope anyone can help me figure this out cause I'm stuck.
/A-Hed
Here is a test game to make it easier to understand what may be wrong:
http://www.geocities.com/scorpiorus82/animategb.zip (copy&paste the link)
Hope it helps :)
Thank you very much!!
I know what I did wrong now, very stupid mistake but it's solved now.
Thanks again, now I can get back to studying on how to script in of 2.7 :)
/A-Hed
Cool Scorpiorus, that will come in handy for me .
We need more stuff like that for people .
Quote from: A-Hed on Sun 18/09/2005 01:23:58
Thank you very much!!
No problem, I'm glad it works! :)
The reason I decided to upload an example is because it's rather difficult to figure out what bit is wrong.
Quote from: Candle on Sun 18/09/2005 07:06:29
Cool Scorpiorus, that will come in handy for me .
We need more stuff like that for people .
You know, I entirely agree -- with working test games it's much easier to figure out the problem than if you post the code directly -- no copy&paste issues in that case. ;)