Jump to content

move dx position


Wisin

Recommended Posts

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.

Link to comment

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?

Link to comment

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 

Link to comment

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 
  

Link to comment

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...