Jump to content

[Help] Math based animation problem


PartyMTA

Recommended Posts

//With math based animation i mean ex; alpha = alpha + 1

Hello everyone. I am working on login panel with animation like mentioned above this line.

Running the event first time works fine, but when i run it AGAIN, it doesnt detect when to stop.

First time run is when resource start, and second time when i click a button (which does it perfectly)

  
function loginAnim() 
    if components.login.startPosX>stopanimpos1 then 
        components.login.startPosX = components.login.startPosX - 10 
        if components.login.startPosX==stopanimpos1 then 
            components.login.startPosX = stopanimpos1 
        end 
    end 
end 
  
function loginAnim2() 
    if components.login.startPosX<=stopanimpos1 then 
        components.login.startPosX = components.login.startPosX - 10 
        if components.login.startPosX==0 then 
            removeEventHandler("onClientRender",getRootElement(),login) 
            components.login.startPosX = x 
        end 
    end 
end 
  

loginAnim is for opening, loginAnim2 for closing.

It's windows 8 styled btw

Link to comment

Please remember animations (If they're smooth) can always exceed the == parameter, (1.009 instead of 1), use >= and <= instead.

For example:

  
local start = getTickCount() 
function call() 
local now = getTickCount() 
local progress = (now-start)/1000 
  
if progress >= 1 then -- Progress of exact values can often be overriden 
removeEventHandler('onClientRender',root,call) 
end 
  
end 
addEventHandler('onClientRender',root,call) 
  

Else, i cant find any other problem in this code, if my posted solution doesnt work, post the rest of the code wich involves this (Mainly the variables wich you're using and what this affects)

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