可以将变量存储在另一个存储类中吗?

时间:2016-04-16 08:42:28

标签: android variables

将变量存储在另一个存储类中是否可以?像这样:

function render(){

    renderer.clear();


    camera.lookAt(scene.position);

    walk();

    renderer.render(scene, camera);
    requestAnimationFrame(render);
}


render();

function walk(){

    //EVENTS lauschen
    var delta = clock.getDelta();

    var physisMove = 10;

    if(keyboard.pressed('left')){
        mover.setAngularVelocity({z:0,y:1,x:0});
        istMoveLeft = true;
    }

        if(keyboard.pressed('up')){
            mover.setLinearVelocity({z: -physisMove, y:0,x:0});
            isMoveForward = true;
        }

        if(keyboard.pressed('right')){
            mover.setAngularVelocity({z:0,y:-1,x:0});
            isMoveRight = true;
        }

        if(keyboard.pressed('down')){
            mover.setLinearVelocity({z: physisMove, y:0,x:0});
            isMoveBackward = true;
        }

    document.addEventListener("keyup", function(event){
      var code = event.keyCode;
        if(code == 38) mover.setLinearVelocity({z:0, y:0,x:0});
        if(code == 40) mover.setLinearVelocity({z:0, y:0,x:0});
        if(code == 37){
            mover.setLinearVelocity({z:0, y:0,x:0});
            mover.setAngularVelocity({z:0,y:0,x:0});
        }
        if(code == 39){
            mover.setLinearVelocity({z:0, y:0,x:0});
            mover.setAngularVelocity({z:0,y:0,x:0});
        }

    });
    mover.setAngularFactor({z:0,x:0,y:0});

    /*
    document.addEventListener('keyup', function(event){
        var code = event.keyCode;
        if(code == 37) istMoveLeft = false;
        if(code == 38) isMoveForward = false;
        if(code == 39) isMoveRight = false;
        if(code == 40) isMoveBackward = false;

    });
    */
}

并在活动中使用它们?

2 个答案:

答案 0 :(得分:0)

试试这个

    //create a object for class
    RequestCode rc=new RequestCode();

     public int urValue = rc.REQUIEST_CODE_NAME ;

   //or

   public int urValue = RequestCode.REQUIEST_CODE_NAME ;

答案 1 :(得分:0)

是的,使用第一种方法(声明它们RequestCode.REQUIEST_CODE_lANG),这样您就可以在没有类实例化的情况下访问它们,例如{{1}}。