GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 Re: GML Code Help » Instance_Create Buttons » 2011-03-20 15:05:08

Thanks for that, didn't expect to get a response that fast!!
Damn near got the answer before I'd finished the question.:lol:

Ok I placed the code in the create event and it placed 10 buttons on screen each with a different image_index.
But how do I keep the information so that I can use it later in the game.
For example if I click LMB on button 5 it will say you pressed button 5.
That's not the effect but if it does that then I know it works and can then add better events for when a particular button is pressed.

Edited:

Used this
global.MyID[i] = i;

which gives each button a number that can now be used else where in the game.
I think it's the right way to do it?

#2 GML Code Help » Instance_Create Buttons » 2011-03-20 14:42:20

Anybloodyid
Replies: 2

I'm trying to create 10 buttons in a row, here's what I have in a controller Create event.

Expandfor (i=1; i<=10; i+=1) 
    {
    instance_create(300 + 48*(i-1), 300, obj_button_add)
}

This does what I want but the 10 sub-images on each instance created spin around.
How can I create 10 individual buttons each showing only one sub-image and each having it's own id?
ie
Button_1,sub_image_0
Button_2,sub_image_1
Button_3,sub_image_2

So that I know which button the mouse pressed.
I have tried all sorts of ways but I've gone round and round so much that I'm now dizzy.

Board footer

Powered by FluxBB