View Single Post
  #6  
Old 01-03-2013, 08:25 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
While using a GUI Control is ideal for stuff related to clicking, with normal displays you could try something such as this:

PHP Code:
//#CLIENTSIDE
function showHUD(){
  
this.addHUDObj(this.showimg(200, "image.png", x, y), 32, 32, 4);

  
this.addHUDObj(this.showimg(201, "image2.png", x, y), 64, 64, 4);

  
temp.t = this.showtext(202, x, y, "tempus sans itc", "b", "text");
  
temp.t.zoom = 0.5;
  
temp.w = gettextwidth(temp.t.zoom, temp.t.font, temp.t.style, temp.t.text);
  
temp.h = gettextheight(temp.t.zoom, temp.t.font, temp.t.style, temp.t.text);
  
this.addHUDObj(temp.t, temp.w, temp.h, 5);
}

function 
addHUDObj(temp.display, temp.w, temp.h, temp.layer){
  
temp.display.dwidth = temp.w;
  
temp.display.dheight = temp.h;
  
temp.display.layer = temp.layer;
  
this.displays.add(temp.display);
}

function 
onMouseDown(temp.button) {
  if(
temp.button != "left")
    return;

  for(
temp.d : this.displays){
    if(
      
mousescreenx in <temp.d.x, temp.d.x + temp.d.dwidth> &&
      
mousescreeny in <temp.d.y, temp.d.y + temp.d.dheight>
    ){
      
this.startDrag(temp.d);
      return;
    }
  }
}

function 
startDrag(temp.d){
  
this.dragobj = temp.d;
  
this.draglayer = this.dragobj.layer;
  
this.draglayer = 6;
  
this.dragoffx = mousescreenx - this.dragobj.x;
  
this.dragoffy = mousescreeny - this.dragobj.y;
  
this.scheduleEvent(0.05, "Drag", "");
}

function 
onDrag(){
  if(!
leftmousebutton){
    
this.dragobj.layer = this.draglayer;
    return;
  }
  
this.dragobj.x = min(max(0, mousescreenx - this.dragoffx), screenwidth - this.dragobj.dwidth);
  
this.dragobj.y = min(max(0, mousescreeny - this.dragoffy), screenheight - this.dragobj.dheight);
  
this.scheduleEvent(0.05, "Drag", "");
} 

Last edited by ffcmike; 01-03-2013 at 08:38 PM..
Reply With Quote