Wisin Posted October 21, 2010 Share Posted October 21, 2010 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? Link to comment
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 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 Link to comment
50p Posted October 21, 2010 Share Posted October 21, 2010 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
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 whops, i didnt read carefully Link to comment
Wisin Posted October 21, 2010 Author Share Posted October 21, 2010 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
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 do you have onClientRender event handler? or you have no idea about dx drawing? (if no idea -> https://wiki.multitheftauto.com/wiki/DxDrawText or any dx function on wiki) Link to comment
Wisin Posted October 21, 2010 Author Share Posted October 21, 2010 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. Link to comment
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 hmm, tell me what is that 19.0 ? it should be color variable.. arguments are invalid Link to comment
Wisin Posted October 21, 2010 Author Share Posted October 21, 2010 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
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 why you ahve changed y to y2? and on like 4 you have y = ... Link to comment
Wisin Posted October 21, 2010 Author Share Posted October 21, 2010 thats because it was messing with a different script cause i use also, x,y = guiGetScreenSize() Link to comment
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 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
Wisin Posted October 21, 2010 Author Share Posted October 21, 2010 yeah, its moving now but at wrong part of screen, it moves up but the rectangle position is wrong. Link to comment
dzek (varez) Posted October 21, 2010 Share Posted October 21, 2010 you can mess with the variables now - code is commented so you have to find out what is what Link to comment
Wisin Posted October 21, 2010 Author Share Posted October 21, 2010 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 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now