sprite as a button

Started by MEGAMIND, Aug 20, 2017, 07:54 PM

Previous topic - Next topic

MEGAMIND

hey guyyz how to have a sprite as a button?

test <- null;
 
function Script::ScriptLoad()
{
:: test = GUISprite("tesst.png", VectorScreen(x, y));
::GUI.SetMouseEnabled(true);
}

EK.IceFlake

You need to add the flag GUI_MOUSE_CTRL and then use it as a normal button.

MEGAMIND

#2
sir any code for reffernece

test <- null;
function Script::ScriptLoad()
{
GUI.SetMouseEnabled(true);
:: test = GUISprite("tesst.png", VectorScreen(0, 0));
:: test.Size = VectorScreen(35, 100);
:: test.AddFlags(GUI_FLAG_MOUSECTRL);
}

MatheuS

test <- null;
 
function Script::ScriptLoad()
{
::test = GUISprite("tesst.png", VectorScreen(x, y));
::test.AddFlags(GUI_MOUSE_CTRL);
::GUI.SetMouseEnabled(true);
}

function onElementClick(balblablablalbala)
{
          if( element == ::test ) JUST_DO_IT();
}
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

MEGAMIND

test <- null;
 
function Script::ScriptLoad()
{
::test = GUISprite("tesst.png", VectorScreen(0, 0));
::GUI.SetMouseEnabled(true);
::test.AddFlags(GUI_MOUSE_CTRL);
}

function onElementClick(element, mouseX, mouseY)
{
          if (element == ::test)
{
local D = Stream();
D.WriteString("Delettest");
Server.SendData(D);
}
::GUI.SetMouseEnabled(false);
}
function Server::ServerData(stream)
{
local ReadStri = stream.ReadString();
if(ReadStri=="DelettestSide")
{
::test<-null;//Delete
}
}

not working i want to click the image and then the image and mouse should get closed