ActionScript 3 Cant see Movieclip

Posted by user3697993 on Stack Overflow See other posts from Stack Overflow or by user3697993
Published on 2014-06-02T02:41:56Z Indexed on 2014/06/02 3:26 UTC
Read the original article Hit count: 128

Filed under:
|

When I play my game it does not show my _Player Movieclip, but it does collide with the ground which is very confusing. So I believe the movieclip is there but not showing the texture/Sprite.

I think the problem is in "function Spawn" (First Function).

 public class PewdyBird extends MovieClip
{

    //Player variables
    public var Up_Speed:int = 25;
    public var speed:Number = 0;
    public var _grav:Number = 0.5;
    public var isJump:Boolean = false;
    public var Score:int = 0;
    public var Player_Live:Boolean = true;
    public var _Player:Player = new Player();
    //Other variables

    //Environment variables
    var Floor:int = 480;
    var Clock:Number = 0;
    var Clock_restart:Number = 0;
    var Clock_ON:Boolean = false;
    var Clock_max:int = 15;
    var Player_Stage:Boolean = true;
    private var _X:int;
    private var _Y:int;
    private var hit_ground:Boolean = false;
    private var width_BG:int = 479;

    //SPAWN
    function Spawn(e:Event){
        _Player.x = 200;
        _Player.y = 200;

        stage.addChild(_Player);
    }

    //Keyboard Input
    private function KeyboardListener(e:KeyboardEvent){
        if(e.keyCode == Keyboard.SPACE){
            Clock = Clock_restart;
            Clock_ON = true;
            isJump = true;

            if(isJump){
                _Player.gotoAndPlay("Fly");
                speed = -Up_Speed;
                isJump = false;
            }
        }
    }

    //Mouse Input & Spawn Listener
    private function MouseListener(m:MouseEvent){
        if(MouseEvent.CLICK){
            Clock = Clock_restart;
            Clock_ON = true;
            isJump = true;

            if(isJump){
                _Player.gotoAndPlay("Fly");
                speed = -Up_Speed;
                isJump = false;
            }   

        }
    }

    //Rotation Fly
    function Rot_Fly(){

        if(Clock < Clock_max){
            _Player.rotation = -15;

        }else if(Clock >= Clock_max){

            if(_Player.rotation < 90){
                _Player.rotation += 10;

            }else if(_Player.rotation >= 90){
                _Player.rotation = 90;

            }

        }   
    }
    //END

    //Update Function
    function enter_frame(e:Event):void{
        Rot_Fly();

        //Clock 
        if(Clock_ON){
            Clock++;
        }else if(Clock > Clock_max){
            Clock = Clock_max;
        }

        //Fall Limits
        if(speed >= 20){
            _Player.y += 20;
            return;
            _Player.gotoAndPlay("Fall");
        }
        //Physics
        speed += _grav*3;
        _Player.y += speed;
    }


    //Hit Ground
    function Hit_Ground(e:Event){

        if(_Player.hitTestObject(Ground1)){
            _grav = 0;
            speed = 0;
            trace("HIT GROUND");
        }else if(_Player.hitTestObject(Ground2)){
            _grav = 0;
            speed = 0;
            trace("HIT GROUND");
        }else if(_Player.hitTestObject(Ground1) == false){
            _grav = 1;
        }else if(_Player.hitTestObject(Ground2) == false){
            _grav = 1;
        }
    }


    //Background Slide (Left)
    private function Background_Move(e:Event):void{
        Background1.x -= 1.5;
        Background2.x -= 1.5;
        Ground1.x -= 4;
        Ground2.x -= 4;

        if(Background1.x < -width_BG){
            Background1.x = width_BG;
        } else if(Background2.x < -width_BG){
            Background2.x = width_BG;
        } else if(Ground1.x < -width_BG){
            Ground1.x = width_BG;
        } else if(Ground2.x < -width_BG){
            Ground2.x = width_BG;
        }
    }


}

The eventListeners are in flash it self

stage.addEventListener(Event.ENTER_FRAME, enter_frame);
stage.addEventListener(Event.ENTER_FRAME, Hit_Ground);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyboardListener);
stage.addEventListener(MouseEvent.CLICK, MouseListener);
stage.addEventListener(Event.ENTER_FRAME, Background_Move); 
stage.addEventListener(Event.ADDED_TO_STAGE, Spawn);

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about movieclip