Button NormalGraphic (solved)

Started by Virgil, Thu 31/12/2009 01:00:50

Previous topic - Next topic

Virgil

I've looked around in the forums, and for some reason I still get the same problem. I want to change a button's normalgraphic on the click of another button.

when i do something like: int button.NormalGraphic = 1;

I get the error "Expected ',' or ';' not '.'

Obviously if I change to a comma it won't run.

monkey0506

You may want to take a look at the scripting tutorial in the manual first to learn how to script in AGS. When you type:

Code: ags
int button


AGS thinks you are defining a new variable named "button" of type int. What you're trying to do, as you said, is access the existing NormalGraphic property of your button. So what you need to do is something such as:

Code: ags
btnButtonName.NormalGraphic = SLOT_NUMBER;


Where btnButtonName is the script o-name of your button (as defined by the "Name" setting in the editor with the button selected) and SLOT_NUMBER of course is the sprite slot number you want to use.

When you're just accessing existing variables or properties you don't have to tell AGS that you're working with an int property, it will already know when you access the NormalGraphic property.

Oh, and one last thing, you can use the [code] and [/code] tags to encapsulate your code like I did above. ;)

Virgil

See, I thought I had it right, but I guess not. I know about the declaring but I must have misread the forums. Anyways, fine, thanks.

monkey0506

Glad to hear you got it sorted out. Just keep in mind that unless you're defining a new variable or function parameter then you don't need to put the type. ;)

Good luck with your game! :)

SMF spam blocked by CleanTalk