View Full Version : some Nice movement
ricer
April 14th, 2006, 05:22 AM
heya, im creating a new project
a game thats something like this:
http://www.armorgames.com/games/armorheroes_popup.html
but i need a nice movement for jumping and stuff
the left and right is easy
i made a little script but can someone make it with jumping?
onClipEvent(load){
walkspeed = 0;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.LEFT)) {
_x -= _root.walkspeed
_root.hero.gotoAndPlay("walkleft");
}
if (Key.isDown(Key.LEFT)) {
_x += _root.walkspeed
_root.hero.gotoAndPlay("walkright");
}
}
thats it :)
thnx ^^
KIERIOSHIMOTO
April 14th, 2006, 05:48 AM
heya, im creating a new project
a game thats something like this:
http://www.armorgames.com/games/armorheroes_popup.html
but i need a nice movement for jumping and stuff
the left and right is easy
i made a little script but can someone make it with jumping?
ActionScript Code:
onClipEvent(load){
walkspeed = 0;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.LEFT)) {
_x -= _root.walkspeed
_root.hero.gotoAndPlay("walkleft");
}
if (Key.isDown(Key.LEFT)) {
_x += _root.walkspeed
_root.hero.gotoAndPlay("walkright");
}
}
thats it :)
thnx ^^
Why dont you try Nathan's platform tutorial here. (http://n99creations.com/?pID=tutorials&col=Blue&tut=create_platform_game&p=1&l=Flash_MX_04)
Joppe
April 14th, 2006, 06:05 AM
onClipEvent (load) {
walkspeed = 0;
jump = 6;
grav = 0;
jumpin = false;
fall = true;
}
onClipEvent (enterFrame) {
trace(jump);
if (jumpin) {
jump += 2;
_y -= jump;
if (jump>=16) {
jumpin = false;
}
}
if (!this.hitTest(_root.ground) && !jumpin) {
fall = true;
grav++;
}
if (fall) {
_y += grav;
}
if (this.hitTest(_root.ground)) {
fall = false;
grav = 0;
jump = 0;
jumpin = false;
}
if (Key.isDown(Key.LEFT)) {
_x -= walkspeed;
_root.hero.gotoAndPlay("walkleft");
}
if (Key.isDown(Key.LEFT)) {
_x += walkspeed;
_root.hero.gotoAndPlay("walkright");
}
if (Key.isDown(Key.UP)) {
if (!fall && !jumpin) {
jumpin = true;
fall = false;
}
}
}
Maybe something like that?
ricer
April 14th, 2006, 07:05 AM
ai thnx :D
it works :D:D:D:D damn ur a genious joppe
(as always) :P ur always here to help me :p thnx man
if there's anything i can do for u just ask :p
bombsledder
April 14th, 2006, 10:13 AM
:P i love it people give simple codes and there genious lol
nathan99
April 14th, 2006, 10:17 AM
hehe yeah I noticed that.. BUT... I let them have a shot at glory... But you know I may just be a good person..
bombsledder
April 14th, 2006, 12:25 PM
hehe im going to start giving all codes away that people ask for and maybe i could get some recognition =(
Joppe
April 14th, 2006, 12:57 PM
why wouldnt you help people?
nathan99
April 14th, 2006, 08:38 PM
sorry jop..:cantlook:
here is my version, it's just very simple and will need tweaking... but useable:
the game runs off this code
var moveHorizontalSpeed:Number = 1;
var moveVerticalSpeed:Number = 1;
var space:Number = 5;
var launchInit:Number = -10;
var mapScrollDist:Number = 100;
k.onEnterFrame = function() {
Key.isDown(Key.SPACE) && !jumping ? (yLaunch=this._y, jumping=jumpSpeed=launchInit) : this._y>=yLaunch && jumpSpeed>0 ? (this._y=yLaunch, jumpSpeed=launchInit, jumping=false) : jumping ? (this._y += jumpSpeed++, this.gotoAndStop("jump")) : null;
this._y -= yspeed=moveVerticalSpeed*(Key.isDown(Key.UP)-Key.isDown(Key.DOWN));
Key.isDown(Key.LEFT) && this._x<0+mapScrollDist && g.getBounds(_root).xMin<0+moveHorizontalSpeed ? g._x += moveHorizontalSpeed : Key.isDown(Key.RIGHT) && this._x>Stage.width-mapScrollDist && g.getBounds(_root).xMax>Stage.width-moveHorizontalSpeed ? g._x -= moveHorizontalSpeed : this._x -= speed=moveHorizontalSpeed*(Key.isDown(Key.LEFT)-Key.isDown(Key.RIGHT));
speed != 0 ? ((this._xscale=speed<0 ? 100 : -100), (!jumping ? this.gotoAndStop("walk") : null)) : yspeed ? (!jumping ? this.gotoAndStop("walk") : null) : (!jumping ? this.gotoAndStop("idle") : null);
while (this._y<g._y && !g.h.hitTest(this._x, this._y, true) && !jumping) {
this._y++;
}
while (this._y>g._y && !g.h.hitTest(this._x, this._y, true) && !jumping) {
this._y--;
}
while (!g.h.hitTest(this._x-space, this._y, true) && !jumping) {
this._x++;
}
while (!g.h.hitTest(this._x+space, this._y, true) && !jumping) {
this._x--;
}
};
hybrid101
April 14th, 2006, 11:44 PM
tjat's pretty complicated for beginners, nathan:)
nice one joppe:) simple and effective
nathan99
April 14th, 2006, 11:46 PM
hehe, yeah I thought that.. but its simple to me... I guess i forgot how hard it is to grasp as
ricer
April 15th, 2006, 04:13 AM
thnx nathan :)
ok i'll tell u it 2 then :p Nathan ur a genious too man!!! thnx :D :p:p:p
Joppe
April 15th, 2006, 07:36 AM
Actually Nathans the only genious of us too. I learnt how to do the jumping while reading his tutorial. Had no idea before ;)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.