This is my own code
Study it
and use it how you need
loading images and setting them to buttons
Function AddPlayerControl()
//--------------------------------------------------------------------//
// Check to see if a controller is pluged in
//--------------------------------------------------------------------//
CompleteRawJoystickDetection()
Global connected
connected= GetRawJoystickConnected( 1 )
if connected=0
ButtonA=LoadImage("Xbox 360 Controller Buttons/ButtonA.png")
ButtonB=LoadImage("Xbox 360 Controller Buttons/ButtonB.png")
ButtonX=LoadImage("Xbox 360 Controller Buttons/ButtonX.png")
ButtonY=LoadImage("Xbox 360 Controller Buttons/ButtonY.png")
DpadDown=LoadImage("Xbox 360 Controller Buttons/DpadDown.png")
DpadLeft=LoadImage("Xbox 360 Controller Buttons/DpadLeft.png")
DpadRight=LoadImage("Xbox 360 Controller Buttons/DpadRight.png")
DpadUp=LoadImage("Xbox 360 Controller Buttons/DpadUp.png")
//--------------------------------------------------------------------//
// Right button
//--------------------------------------------------------------------//
AddVirtualButton(2,50,25,18)
SetVirtualButtonPosition(2,10,75)
SetVirtualButtonActive(2,1)
SetVirtualButtonImageUp(2,DpadRight)
SetVirtualButtonImageDown(2,DpadRight)
//--------------------------------------------------------------------//
// Left button
//--------------------------------------------------------------------//
AddVirtualButton(3,50,25,18)
SetVirtualButtonPosition(3,-20,75)
SetVirtualButtonActive(3,1)
SetVirtualButtonImageUp(3,DpadLeft)
SetVirtualButtonImageDown(3,DpadLeft)
//--------------------------------------------------------------------//
// Up button
//--------------------------------------------------------------------//
AddVirtualButton(4,50,25,18)
SetVirtualButtonPosition(4,-5.3,60)
SetVirtualButtonActive(4,1)
SetVirtualButtonImageUp(4,DpadUp)
SetVirtualButtonImageDown(4,DpadUp)
//--------------------------------------------------------------------//
// Down button
//--------------------------------------------------------------------//
AddVirtualButton(5,50,25,18)
SetVirtualButtonPosition(5,-5.3,90)
SetVirtualButtonActive(5,1)
SetVirtualButtonImageUp(5,DpadDown)
SetVirtualButtonImageDown(5,DpadDown)
//--------------------------------------------------------------------//
// a button
//--------------------------------------------------------------------//
AddVirtualButton(9,50,25,15)
SetVirtualButtonPosition(9,105,90)
SetVirtualButtonActive(9,1)
SetVirtualButtonImageUp(9,ButtonA)
SetVirtualButtonImageDown(9,ButtonA)
//--------------------------------------------------------------------//
// b button
//--------------------------------------------------------------------//
AddVirtualButton(10,50,25,15)
SetVirtualButtonPosition(10,120,75)
SetVirtualButtonActive(10,1)
SetVirtualButtonImageUp(10,ButtonB)
SetVirtualButtonImageDown(10,ButtonB)
//--------------------------------------------------------------------//
// x button
//--------------------------------------------------------------------//
AddVirtualButton(11,50,25,15)
SetVirtualButtonPosition(11,90,75)
SetVirtualButtonActive(11,1)
SetVirtualButtonImageUp(11,ButtonX)
SetVirtualButtonImageDown(11,ButtonX)
//--------------------------------------------------------------------//
// y button
//--------------------------------------------------------------------//
AddVirtualButton(12,50,25,15)
SetVirtualButtonPosition(12,105,60)
SetVirtualButtonActive(12,1)
SetVirtualButtonImageUp(12,ButtonY)
SetVirtualButtonImageDown(12,ButtonY)
endif
endfunction
Small example how to use the buttons
for allbuttons=2 to 5
if GetVirtualButtonState(allbuttons)
SetVirtualButtonColor(allbuttons,55,55,255)
else
SetVirtualButtonColor(allbuttons,255,255,255)
endif
next allbuttons
for allbuttons=9 to 12
if GetVirtualButtonState(allbuttons)
SetVirtualButtonColor(allbuttons,55,55,255)
else
SetVirtualButtonColor(allbuttons,255,255,255)
endif
next allbuttons