Hi,
I have got some buttons whit move over graphics on, so that will work when I put my mouse over it. Now I want, when I press a key on the keyboard, I want the button change for a second and then carry on with the game.
I have tried this,
if(keycode == 'J'){Button[12].MouseOverGraphic();}
but this doesn't work.
Any ideas?
That doesn't work because that's not how you're supposed to use that property. It's not a function, so you don't need parentheses(), and I have no idea how you came up with the Button[] that you're calling it on.
Sorry, but RTM.
~Trent
Unless Button[] is an array you've set up somewhere, or just pseudocode?
What you need to do is save the normal graphic (so you can change back), change the graphic, then change it back. Something like
if (keycode == 'J') {
int oldGraphic = bTest.NormalGraphic; // save current graphic
bTest.NormalGraphic = bTest.MouseOverGraphic; // change
Wait(20); // wait a bit
bTest.NormalGraphic = oldGraphic;
}
That'll change it for about 1/2 a second (pausing the game) then change back. If you want it to stay changed while J is pressed, you're looking at IsKeyPressed and repeatedly_execute() scripting.
Quote from: GuyAwesome on Sun 07/06/2009 23:21:55
int oldGraphic = bTest.NormalGraphic; // save current graphic
is 'int oldgraphic' a built in function already or do you have to put it in by yourself?
You'll have to put it in yourself. Just put that code into on_key_press, and replace bTest with the name of the button you want to change. Other than that, the code should work perfectly. What it does is a bit crap, but it does it perfectly :)
Quote from: shaungaryevans on Sun 07/06/2009 23:50:33
is 'int oldgraphic' a built in function already or do you have to put it in by yourself?
int oldgraphic is being defined in that line, so no, it doesn't exist anywhere.
~Trent
Another question now,
I have worked out the mouse over another way but thanks for your help.
When I put the 'wait' function in, when it doing it the buttons go semi-transparent. Why does this happen and how can i sort it out please?
Because the Wait command pauses the game, and I'd guess that's what you've got the GUIs set to do when they're disabled...
There's an option to change that in General Settings ('When player interface is disabled, GUIs should'), or you can use SetGameOption to change it in-game. Check the manual for the right parameters to use.
BTW, what did you end up doing for the mouseover thing?
I will post it when i have done this bit
Thank you very much. I went back of using the code on here, so much easier and quicker, thank you for helping me :) :) :) :) :) :)
Can sombodt work this out:
code:
if(rroom.Visible == true) {if(keycode == 'N') {int vrroom_no = rroom_no.NormalGraphic; vrroom_no.NormalGraphic = rroom_no.MouseOverGraphic; Wait(20); vrroom_no.NormalGraphic = vrroom_no; Wait(5);
error in code:
GlobalScript.asc(188): Error (line 188): '.NormalGraphic' is not a public member of 'int'. Are you sure you spelt it correctly (remember, capital letters are important)?
it will be something simple i hope, i'm just tried sorry.
thanks
It's exactly has it is telling you. You're trying to get a NormalGraphic from a int.
You've had a very similar problem before (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37642.msg495048#msg495048) and you were also told (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=35955.msg471228#msg471228) to modify your posts.
~Trent
Specificaly, I think this is a typo. You've got vrroom_no.NormalGraphic = (and twice at that), when you should have rroom_no.NormalGraphic =. It'd be a lot easier to spot where the problem was if you used indentation, like my code (not that it's perfect by any means). (Unless that's just how you've typed it up, and you've got indentation in the real script - in which case USE IT HERE :))
But yeah, basically the same problem as Trent linked to. Always double and triple check that stuff!
EDIT:
You're also missing two closing }'s, but I'm guessing/hoping that's just cause you didn't copy them, not because they're not there..
It works perfectly now, that whats counts