예제 #1
0
    void initScrolling()
    {
        // init all frames
        foreach( ScrollingScript frame in scrollings ) {

            //frame.gameObject.SetActive( false );
            //frame._Speed = this._Speed;
            frame._Speed = _Speed;
            frame._Direction = _Direction;
            frame.SetActive( false );
        }

        _currentScrolling = 0;
        _currentFrame = getFrame( _currentScrolling );
        // todo: determine init pos;
        float initPosX = 0;
        float initPosZ = 2;
        float initPosY = 0;

        if( _Direction > 0 ) {
            // move up
            initPosY = 0;
        }
        else {
            // move down
            initPosY = _currentFrame.sizeHeight / 2 - _screenUnitHeight;
        }

        _currentFrame.movePosition( new Vector3( initPosX, initPosY, initPosZ ) );
        _disapperPosY = _currentFrame.calcDisapperPosY( _screenUnitHeight );

        ScrollingScript nextFrame = getFrame( nextScrolling() );
        nextFrame.moveFollowFrame( _currentFrame );

        // active
        _currentFrame.SetActive( true );
        nextFrame.SetActive( true );

        //Transform tScrolling = scrolling.gameObject.transform;
        //tScrolling.position = new Vector3(0,0,2);

        Debug.Log ( "Manager initScrolling" );
    }
예제 #2
0
    void Update()
    {
        /*
        float Move = _Speed * Time.deltaTime;
        transform.Translate(Vector3.down * Move,Space.World);
        */

        /*
        if(transform.position.y<-20)
        {
            transform.position = new Vector3(transform.position.x,
                                             20,transform.position.z);
        }
        */

        if( _currentFrame ) {

            bool bDisapper = false;
            if( _Direction > 0 ) {
                // move up
                if( _currentFrame.transform.position.y > _disapperPosY ) {
                    bDisapper = true;
                }
            }
            else {
                // move down
                if( _currentFrame.transform.position.y < _disapperPosY ) {
                    bDisapper = true;
                }
            }

            if( bDisapper ) {

                // de-active disapper frame
                _currentFrame.SetActive( false );

                // link next frame
                _currentScrolling = nextScrolling();
                _currentFrame = getFrame( _currentScrolling );
                _disapperPosY = _currentFrame.calcDisapperPosY( _screenUnitHeight );

                ScrollingScript nextFrame = getFrame( nextScrolling() );
                nextFrame.moveFollowFrame( _currentFrame );

                // active next frame
                nextFrame.SetActive( true );
            }
        }
    }