Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 08-21-2012, 01:57 AM   #1
bryser1
Registered User
 
Join Date: Nov 2010
Posts: 11
Default rotation on a slope

hey guys,

I have some rotation code for a slope:
_________________________________________

function onEnterFrame() {

var leftist:Object = {xlank.leftdot._x, ylank.leftdot._y}
plank.leftdot.localToGlobal(leftist);

var rightist:Object = {xlank.rightdot._x, ylank.rightdot._y}
plank.rightdot.localToGlobal(rightist);

plank._x = _xmouse; plank._y = _ymouse;
if (hill.hitTest(leftist.x, leftist.y, true)) {left = true;}
else {left = false;}
if (hill.hitTest(rightist.x, rightist.y, true)) {right = true;}
else {right = false;}

if (right == true && left == false)
{plank._rotation-=2; trace("right only");}
else if (right == false && left == true)
{plank._rotation+=2; trace("left only");}
else if (right == false && left == false)
{ trace("neither only");}
else if (right == true && left == true)
{ trace("both only");}


lefty._x = (leftist.x);
lefty._y = (leftist.y);

righty._x = (rightist.x);
righty._y = (rightist.y);
}
__________________________________________

when I changed the name 'plank' to 'guyOnHorse' using the code below, the gravity, pulls the whole lot off the bottom of the screen:
_________________________________________

onClipEvent (load) {
speed = 3.6;
gravity = 0;
r = _height/29;
jumping = false;
var scale:Number = _xscale;
jumpheight = 11;
running = false;
var touchingGround = false;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_xscale = +scale;
if(touchingGround == true) {
this.gotoAndPlay("walk");
}
_x += Walkspeed;
}
if (Key.isDown(Key.LEFT)) {
_xscale = -scale;
if(touchingGround == true) {
this.gotoAndPlay("walk");
}
_x -= Walkspeed;
} else {
if (touchingGround == true) {
this.gotoAndPlay("still");
}
}
if (Key.isDown(Key.UP) && !jumping) {
gravity = -jumpheight;
jumping = true;
this.gotoAndPlay("jump");
}
if (!_root.ground.hitTest(_x, _y, true)) {
gravity++;
_y += gravity;
touchingGround = false;
} else {
jumping = false;
gravity = 0;
}

while (_root.ground.hitTest(_x, _y-1+r, true)) {
gravity = 0;
jumping = false;
_y--;
touchingGround = true;
}
}


Is there anyone who can help, thankyou kindly in advance!
bryser
bryser1 is offline  
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:51 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.