javascript - Change properties of a class from time to time -



javascript - Change properties of a class from time to time -

i have 2 functions. in first 1 increment variable adding 100 , set setinterval funcion repeats after time. other function class, contrusctor create object. want this.x_origen increased adding aumento after time , repeat it. i'm getting here first function increases aument , finishes , sec function starts. how can solve this?

var aument = 0; function aumento(){ aument = aument + 100; homecoming aument; } setinterval(function () {aumento()}, 1000/50); function create_class_brick (x_origen_in, y_origen_in, x_final_in, y_final_in, mi_estado, mi_velocidad, mi_id){ this.x_origen = x_origen_in + aumento(); this.y_origen = y_origen_in; this.x_final = x_final_in + aumento(); this.y_final = y_final_in; this.estado = mi_estado; this.velocidad = mi_velocidad; this.id_elemento = mi_id; this.desplazar_ladrillo = desplazar_ladrillo; this.f0 = f0; this.f2 = f2; this.crear_ladrillo = crear_ladrillo; this.obtener_x_origen_ladrillo = obtener_x_origen_ladrillo; this.obtener_y_origen_ladrillo = obtener_y_origen_ladrillo; this.obtener_x_final_ladrillo = obtener_x_final_ladrillo; this.obtener_y_final_ladrillo = obtener_y_final_ladrillo; }

an illustration on how wait initial call:

function brick (x_origen_in){ this.x_origen = x_origen_in; } function aumento(brick){ console.log(brick.x_origen); brick.x_origen += 100; settimeout(aumento.bind(this, brick), 500); } var brick = new brick(100); aumento(brick);

http://jsfiddle.net/x6c08u39/

javascript

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -