-
Android Scrolling Background
Hi there guys!
I am making a side scrolling runner game in AIR FOR ANDROID ACTIONSCRIPT3.
I have two working buttons: One for the Jump button and One for the Run button - It is already working perfectly.
My character is placed on the center left of the stage so the user has more of a preview before they encounter an obstacle.
Now my problem is how to make the background scroll to the left when the character runs to the right, also the Character can still jump when i press the jump button. I can’t figure it out guys please help! T_T
This is are my codes for the jump and run button:
var dy:Number = 0;
var gravity:Number = 1;
var canjump:Boolean = false;
hero.gotoAndStop('still');
hero.speed = 0;
hero.upval = 0;
right_btn.addEventListener(MouseEvent.MOUSE_DOWN, doRight);
jump_btn.addEventListener(MouseEvent.MOUSE_DOWN, doUp);
stage.addEventListener(MouseEvent.MOUSE_UP, doStill);
stage.addEventListener(Event.ENTER_FRAME,onenter);
function doRight(e:Event):void
{
hero.speed = 5;
hero.scaleX = -1;
hero.gotoAndStop('walking');
}
function doUp(e:Event):void
{
hero.upval = -20;
}
function doStill(e:Event):void
{
hero.upval = 0;
hero.speed = 0;
hero.gotoAndStop('still');
}
function onenter(e:Event):void
{
hero.x += hero.speed;
dy += gravity;
if (hero.y > 441.95)
{
dy = 0;
canjump = true;
}
if (canjump)
{
dy = hero.upval;
canjump = false;
}
hero.y += dy;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|