Jump to content

move dx position


Wisin

Recommended Posts

Posted

hi again, i want to know how i can do like i got a DX rectangle in top of screen and i wanna slowly move it up, how would i do that?

Posted

set a global variables with position, like:

  
posx = 10 
posy = 10 
function drawing() 
  posx=posx+1 
  posy=posy+1 
  -- draw here, using posx, posy as position arguments 
end 
  

Posted

varez, your code would move the rectangle in a diagonal direction (down and right), not up or down.

local y = 0; 
local height = 20; 
function drawRect( ) 
    y = y - 1; 
    dxDrawRectangle( ..., y, .., height, .... ); 
    if y < -height then 
        -- remove handler 
    end 
end 

Don't forget to remove handler for this animation once the rectangle is off screen because it'll keep going up but there is no point if you can't even see it.

Posted

uhm, it dosn't works the rectangle dosn't even appears in screen

  
local y = 0; 
local height = 20; 
function createDX( ) 
    y = y - 1; 
    dxDrawRectangle( 0.0, y, 1023.0, height, 19.0,tocolor(0,0,0,200),false ); 
    if y < -height then 
        removeEventHandler("onClientRender",root,createDX) 
    end 
end 

any idea?

Posted

yes i have idea about DXdrawing and GUI

addEventHandler("onClientRender",root,createDX)

i got the event it works with normal rectangle but not with the one that should move.

Posted

you are right i was doing wrong arguments now it appears but it removes like before, here is my code,

local y2 = 0; 
local height = 20; 
function createDX( ) 
    y = y2 - 1; 
    dxDrawRectangle( 0.0, y2, 1023.0, height, tocolor(0,0,0,200),false ); 
    if y2 < -height then 
        removeEventHandler("onClientRender",root,createDX) 
    end 
end 
  
function removeNews() 
removeEventHandler("onClientRender",root,createDX) 
end 

Posted

and if you change like 4 to y2 = y2 - 1? anyway - it will be removed when y hits -20, which should be done under a sec.

do it like that so you can see what is going on, THEN mess up with variables:

  
local y2 = 300 -- initial y value 
local height = 50 -- height of rectangle 
local width = 400 -- width ... 
local x2 = 300 -- initial x value 
function createDX() 
  y2=y2-1 -- on every frame y will be lowered - causing rectangle to move 
  dxDrawRectangle( x2, y2, width, height, tocolor(0,0,0,200),false ); 
  if y2 < 0 then -- if y will hit the top of screen 
    removeEventHandler("onClientRender",root,createDX) -- remove event 
  end 
end 
  

Posted

yeah i edited it but i got a question, how i can move the text with the timer i made?

edit: also this dosn't works for all resolutions O_o

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...