mustang Posted August 19, 2014 Share Posted August 19, 2014 Iam trying to make draw an img with dxDrawImage but i want to show this img with different rotations for example i want this img to show on resource start with angle of 0 and after one second the angle changes to 10 then after 2 seconds it changes to 20 degrees i tried this x = 0 timer= 0 degree= 0 function drawit() while x <5 do degree = degree+ 10 timer = timer+ 1000 x = x +1 setTimer ( function() img= dxDrawImage(Disk_pos_X, Disk_pos_Y, 100, 100, "img.png", degree, 0, 0, tocolor ( 255, 255, 255, 255 ), true) end, timer, 1 ) end end but it didnt work i used outputChatBox to see what it prints , i noticed that the timer is 5000 which is 5 seconds and the degree is 50 and it prints that 5 times , any solution ? just to mention , if it was only 5 times i would do 5 timers , but iam using it for about 270 - 500 times Thanks. Link to comment
xXMADEXx Posted August 19, 2014 Share Posted August 19, 2014 dxDrawImage returns a boolean, not an element. And you must use it in a render event. But other than that, I think this is what you might've been trying to make local tick; local degree = 0; function dxDrawRotatingImages ( ) if ( not tick ) then tick = getTickCount ( ) end if ( getTickCount ( ) - tick >= 2000 ) then tick = getTickCount ( ) degree = degree + 10 if ( degree >= 360 ) then degree = degree - 360 end end dxDrawImage ( Disk_pos_X, Disk_pos_Y, 100, 100, "img.png", degree, 0, 0, tocolor ( 255, 255, 255, 255 ), true) dxDrawImage ( Disk_pos_X, Disk_pos_Y, 100, 100, "img.png", 0, 0, 0, tocolor ( 255, 255, 255, 255 ), true) end addEventHandler ( "onClientRender", root, dxDrawRotatingImages ) Link to comment
mustang Posted August 19, 2014 Author Share Posted August 19, 2014 I will try that and let you know Link to comment
mustang Posted August 19, 2014 Author Share Posted August 19, 2014 dxDrawImage returns a boolean, not an element. And you must use it in a render event.But other than that, I think this is what you might've been trying to make local tick; local degree = 0; function dxDrawRotatingImages ( ) if ( not tick ) then tick = getTickCount ( ) end if ( getTickCount ( ) - tick >= 2000 ) then tick = getTickCount ( ) degree = degree + 10 if ( degree >= 360 ) then degree = degree - 360 end end dxDrawImage ( Disk_pos_X, Disk_pos_Y, 100, 100, "img.png", degree, 0, 0, tocolor ( 255, 255, 255, 255 ), true) dxDrawImage ( Disk_pos_X, Disk_pos_Y, 100, 100, "img.png", 0, 0, 0, tocolor ( 255, 255, 255, 255 ), true) end addEventHandler ( "onClientRender", root, dxDrawRotatingImages ) Thanks man , worked as i wanted ! 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