neonwarge04 Posted September 16, 2015 Share Posted September 16, 2015 Hi,I am doing a simple tile-base platformer game and implementing the controls for my sprite. My sprite is compose of 6 images for animation so I used the MovieClip to represent my actor. Of course, I need to change the direction of my actor based on the key pressed but I can't seem to do this with MovieClip. Flipping a sprite is fine but not MovieClip.This is what I have so far: this.mMovieClip = new PIXI.extras.MovieClip(this.mAnimFrames); this.mMovieClip.animationSpeed = 0.3; this.mMovieClip.scale.x = -1; this.mMovieClip.anchor.x = 0.5; this.mMovieClip.anchor.y = 0.5;My original sprite if facing to the right. Initially I wanted it facing to opposite direction to test if tipping the scale to other side works. But it isn't. Is there a way to flip the MovieClip to face the other way? Quote Link to comment Share on other sites More sharing options...
neonwarge04 Posted September 16, 2015 Author Share Posted September 16, 2015 Hi,I know now why its not flipping. It seems I am having variables within MovieClip to have NaN. I am not yet moving my sprite horizontally but the debugger is showing that elements .vx and .vy are undefined. Though its unrelated with my original question, but this is causing the flip to fail. I just made sure that during initialization .vx and .vy are defined. And now my sprite is facing the right direction and it moves as well.Also, I flipped first before I started the animation.Moving left: self.mMovieClip.scale.x = -1; self.mMovieClip.play(); self.mMovieClip.vx = -self.mMoveSpeed;Moving right: self.mMovieClip.scale.x = 1; self.mMovieClip.play(); self.mMovieClip.vx = self.mMoveSpeed;And here is how I initialized the movie clip: this.mMovieClip = new PIXI.extras.MovieClip(this.mAnimFrames); this.mMovieClip.animationSpeed = 0.3; this.mMovieClip.scale.x = -1; this.mMovieClip.vx = 0; // not defined initially, so we define it here this.mMovieClip.vy = 0; // not defined initially, so we define it here this.mMovieClip.anchor.x = 0.5; this.mMovieClip.anchor.y = 0.5; this.mMovieClip.stop();Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.