Mouse over graphics(SOLVED).

Started by shaungaryevans, Sun 07/06/2009 22:28:37

Previous topic - Next topic

shaungaryevans

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?

Trent R

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
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

GuyAwesome

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
Code: ags

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.

shaungaryevans

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?

GuyAwesome

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 :)

Trent R

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
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

shaungaryevans

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?

GuyAwesome

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?

shaungaryevans

I will post it when i have done this bit

shaungaryevans

Thank you very much. I went back of using the code on here, so much easier and quicker, thank you for helping me  :) :) :) :) :) :)

shaungaryevans

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

Trent R

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 and you were also told to modify your posts.


~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

GuyAwesome

#12
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..

shaungaryevans

It works perfectly now, that whats counts

SMF spam blocked by CleanTalk