Ground Trouble
I posted this in flash MX a few hours ago, but I didnt get any replies, so I'm posting it here... I use flash MX 2004. Attached is a .fla with a character, coded to move right and left, and jump. But whenever he jumps, he falls through the ground. The ground is an MC with the instance name of ground. Can anyone help? Thanx.
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-28-2004, 09:38 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Actionscript: Ground Trouble
Once again, I'm having trouble with AS in flash =/ Attached is a .fla with a character, coded to move right and left, and jump. But whenever he jumps, he falls through the MC with the instance name of ground. Can anyone help? Thanx.
Ground, Modifying The Ground Midgame
In a game I'm making there is ground that I've drawn out. It isn't flat. I make things fall to it by hitTesting them. How would you make it so that a grenade or something would take out a chunk of the ground so that things fall all the way when they fall?
Ground
Ok, I have a movie clip called ground_mc, and that has all the ground in it. I have another mc called player_mc, and using the arrow keys, you can move the player left, right, jump, duck, etc. How can I get the player to detect if there is a block in it's way so it can't go forward. Also how can I get it to detect if its not on the ground yet (because hitTest won't work because there could be a FLOATING block). Please help!!!
Ground
I posted my question in the newbie section but no one knows, so can someone from here help? The post is located here. Thanks!
Ground...
hello all... does any one have an idea on how to rotate something to follow the ground its on...
like if i had a bike, and it was going up an inclined plane... and i had a gravity code on it... and a hittest on the ground.. how would i get it to rotate depending on how steep the plane is?
Backing The GROUND
what is the best way to do scrolling bacground?? but when u want it to go from middle of the screen to the end of screen?? something like scrolling earth in some airplane simulator. some advice please
Back Ground Help
Hi im wondering how to make my back ground to show through my banner and buttons and also im having problems insertin flash into frontpage2002 can you post the insertion script plz
Ground Boundaries
Im also making a mega man game and need help for ground boundaries.
Thanks for any help
Back Ground
i want a gradient for my back ground but when i export it into html i have a frame around the box i drew and filled with the gradient...i have experientmented with the fram size in the properties of the flash file and have made the box w/ the gradient much much bigger than my frame but neither have worked...any ideas?
xxxjosh
What Fps Is Best Middle Ground?
What FPS should I consider using standard in my movies... I am thinking that the higher the fps the smoother things will look and all... but does that significantly affect the size of the movie when I bump it up?
Some thoughts on this would be appreciated!
TIA
Jpg As Back Ground
i have never tried to do this in flash be now its time...i need to use a jpg as the background...i am using mx pro and i know when publishing the html you can select no border but i want the brrowser to match the size of my movie and it puts a border in anyway as some sort of defult flash thing that matches the backgound color...i have done something similar or really exactly the same in dreamweaver then inserted flash elements but i feel like like i want o much to be happening that is flash based to make a few movies that communicate and insert them into an html base, so any help would, um help i guess
MC Hitting The 'ground'
i have a php page where i am loading various swfs.
i want 2 MCs which will be placed in 1 swf (or 2, depending) to 'fall' from the top of the screen and land with a thud and a little random bounce.
the objects need to appear very heavy. I can do this manually, like with frames, but before I do, I am interested in finding out about doing this in AS in a way where each time the object falls the way it hits the horizon line is randomized. I mean the way it bounces slightly.
This will be accompanied by a sound-- imagine a steel plate falling and hitting the pavement (in a 2D world) and then bouncing slightly.
Any suggestions?
How Can I Create This From The Ground?
i downloaded this photo gallery from:
http://laco.wz.cz/tween/?page=examples
i like the way it functions but i can't load it to my stage externaly and i can't seem to import it from one stage to another. i'd like to create a custom version of this file from scratch but i'm seeing things in this file that i've yet to be exposed to.
if someone can tell me what i'm dealing with here. i'd really appreciate it.
i posted the ZIP on my server so have at it!
http://www.monkeyheadgraphics.com/down.zip
thanks in advance,
Andre
monkeyheadgraphics.com
Loading Swf In The Back Ground
i want to load 'juke.swf' while 'lamp.swf' is playing these s.w.files are not related but i want juke to already be loaded before the happy story comes to it.
putting preloder on it won't help, it's a jukebox and is 1 meg. the first movie is small and will stay open in the background while they surf through five pages and ends at juke.swf
is it target load or something or load movie?
i need this for tonight
Scrolling Back Ground
does anyone here has a tutorial or know how to make a scrolling background. i mean like a loony toons like thing where it looks like the guy is moving against a background that just loops over and over
[F8] Gravity/Ground And Walls
New to flash and I'm having some trouble making gravity and having things not go through barriers and walls. I'm using something like " if (this.hitTest(getBounds(_root).xMax, _y, true)) {
_x -= hitback; hitground = true;
}" and its not so good. Sometimes you can fall through the ground and sometimes you bounce. Could anyone give me a script on Walls and gravity and maybe explain it?
Can't Make Ground Green
I'm trying to make a ground for the characters to stand on. I tried to make a parallel line on the bottom of the screen, all the way across, then tried to use the paint bucket to make everythin below the line green. It didn't work. How can I make a ground? Can't I just fraw what I want to use? Help me plz!!!
Back Ground Script.
ok wonder if some one could help please > i wish to use a < for next loop> over a 30 frame anim but i do not want the <for next loop> to complete straight away on the first key frame but over the period of the 30 frame anim.
many thx.
ie: i want the code to run over the period of the anim a little like multi task in the back ground of the anim and not straight away before the anim begins to start.
hope thats clear thx.
need to run action scipt in the back ground while stuff going on sure im missing some thing or is this the nature of flash.
ps.sorry if this has been asked before.
[F8] Rotating Based Off Ground
Im working on a new platform game. I need some help with having the player rotate with the ground.
I have an idea but im sure there is a better way.
My idea is to have two points that are sererate from the player that move independantly on the y axis and are limited to the player on the x axis and the player is moved and rotated to fit in between them.
There are several problems with that though, mainly with jumping and colliding with edges.
[CS3] _y Ground Working With Engine
I am making a game with a few other people, but I am stuck with a bit of actionscript.
Basically I am trying to make it so that when the player reaches a certain height the ground moves downwards so he can continue upwards, however my attempts have not worked.
Heres the script for the engine I am using.
You dont have to read it all but I would just like to know why it isn't working....
thanks for any help.
this.onEnterFrame = function() {
;
;
};
;
function updater() {
;
;
}
;
function collisions() {
;
;
}
;
function brain() {
;
;
}
;
function cleanup() {
;
;
}
stop();
var g = 0.4;
var f = 0.8;
playerbox._y = Stage.height/2;
playerbox._x = Stage.width/2;
playerbox.vx = 0;
playerbox.vy = 0;
playerbox.power = 1;
playerbox.jump = -7.3;
playerbox.jumping = false;
playerbox.health = 50;
enemy.vx = 0;
enemy.vy = 0;
enemy.power = 0.5;
enemy.jump = -8;
enemy.jumping = false;
if(_root.playerbox.hitTest(this)){
_root.playerbox._y-=40;
}
this.onEnterFrame = function() {
brain(enemy, playerbox);
playerbox.vx *= f;
playerbox.vy += g;
playerbox._y += playerbox.vy;
healthbar.gotoAndStop(playerbox.health);
if (playerbox.health<=0) {
cleanup();
}
if (playerbox._x>(Stage.width/2)-20 && playerbox._x<(Stage.width/2)+20) {
ground._x -= playerbox.vx;
enemy._x -= playerbox.vx;
weapon1._x-= playerbox.vx;
gravlift1._x-= playerbox.vx;
holder._x-= playerbox.vx;
grunt._x-=playerbox.vx;
_root["skull"+i+"_"+j]._x-=playerbox.vx;
} else {
playerbox._x += playerbox.vx;
}
updater(enemy);
if (Key.isDown(Key.LEFT) && !_root.ground.hitTest(playerbox._x-(playerbox._width/2)-3, playerbox._y, true)) {
playerbox.vx -= playerbox.power;
} else if (Key.isDown(Key.RIGHT) && !_root.ground.hitTest(playerbox._x+(playerbox._wid th/2)+3, playerbox._y, true)) {
playerbox.vx += playerbox.power;
}
;
if (Key.isDown(Key.UP) && !playerbox.jumping) {
//if the up arrow key is down and the playerbox is not jumping
26.;
playerbox.vy += playerbox.jump;
//add the value of jump to playerboxs vy
27.;
playerbox._y += playerbox.jump;
//move the playerboxs y to prevent it being caught by the collisions.
28.;
playerbox.jumping = true;
//The playerbox is now jumping
29.;
}
//close the if
30.;
collisions(playerbox);
//run the collisions function with "playerbox" as the value of ob
31.;
collisions(enemy);
// run the collisions function with "enemy" as the value of ob
32.;
33.;
};
//close the function
function updater(ob) {
//creates a function called updater with one input variable
ob.vx *= f;
//uses the ob values defined when calling the function to multiply its vx by the friction variable
ob.vy += g;
//add gravity
ob._x += ob.vx;
//update the objects x
ob._y += ob.vy;
//and its y
}
//close the function
function collisions(ob) {
//Create a function called collisions with one input variable.
while (_root.ground.hitTest(ob._x, ob._y-(ob._height/2), true)) {
//while the objects top is inside the ground it will run the following
ob._y += 0.1;
//moves its y position down
ob.vy = 0;
//and set the objects vy to 0 so if it is jumping it will not continue going up.
}
//end the while loop
while (_root.ground.hitTest(ob._x+(ob._width)/3, ob._y+(ob._height/2), true) || _root.ground.hitTest(ob._x-(ob._width)/3, ob._y+(ob._height/2), true)) {
//while the objects lower left or lower right is inside the ground
ob._y -= 0.1;
//Move the objects y position up
ob.vy = 0;
//set its vy to 0 so if it is falling it will stop falling
ob.jumping = false;
//the playerbox is no longer jumping
}
//close the while
while (_root.ground.hitTest(ob._x+(ob._width/2), ob._y-(ob._height/2), true) || _root.ground.hitTest(ob._x+(ob._width/2), ob._y+(ob._height/3), true)) {
//while the objects upper right or lower right is in the ground then
ob._x -= 0.1;
//move the object left
ob.vx = 0;
//set its vx to 0 to stop it from moving
}
//close the while
while (_root.ground.hitTest(ob._x-(ob._width/2), ob._y-(ob._height/2), true) || _root.ground.hitTest(ob._x-(ob._width/2), ob._y+(ob._height)/3, true)) {
//while the objects upper left or lower left is in the ground then
ob._x += 0.1;
//move the object left
ob.vx = 0;
//set its vx to 0
}
//close the while
}
//close the function
function brain(ob,tr){ //Create a function called brain with two input variables ob for object and tr for target
if(ob._x<tr._x-10){ //if the object(enemy) is less then the targets x-10 then
ob.vx+=ob.power; //increase its vx to move it right
}//close the if
else if(ob._x>tr._x+10){//if the above is not true and the object is greater then the target x+10 then
ob.vx-=ob.power;//decrease its vx to move it left
}else if(ob._y>tr._y-(tr._height/2) && ob._y<tr._y+(tr._height/2)){
//if non of the above are true and if the target is within the y boundaries then
tr.health--;//the object is close enough to the target to decrease its health
}//close the else
if(ob._y>tr._y && !ob.jumping && (_root.ground.hitTest(ob._x+(ob._width/2)+3,ob._y,true)|| _root.ground.hitTest(ob._x-(ob._width/2)-3,ob._y,true))){
//if the target is higher then the object and the object is not jumping and the object is against the ground
ob.vy=ob.jump; //set the objects vy to the objects jump
ob._y+=ob.jump; //move the object up.
ob.jumping=true; //the object is now jumping
}//close the if
}//close the function
function cleanup(){ //create a function called function
delete this.onEnterFrame; //delete the onEnterFrame event so it does not continue running
gotoAndStop(2);//move the root timeline to frame 2
}//close the function
if(playerbox._y<=50){
_root.ground._y+=10;
}
if(playerbox._y<=
Bounce Off Curved Ground
Is there a way to get a ball to bounce realistically off of curved ground?
I have the gravity+bounce code already, I just need the code for detecting bounce angle.
Anyone know how to do it?
Help With Making Ground In A Platformer
I used this tutorial to make a platformer, and I have a small problem. It never gave me any AS to put into the ground to stop my guy from falling through. It just tells me to put the little black cross on the bottom, which I did. I don't know how to post the original flash file, which I'm sure would help.
If someone could tell me how to zip files so I can post it here, let me know.
Preloading FLV In The Back Ground
I don't have a file to share yet, but I have a client who needs help with a flash file. They have a FLV running in the background of a larger SWF. The FLV is running to slow. I will have to look at the FLV to make sure the compressed it correctly, but I was wondering how you preload an FLV in the background of an SWF.
Thx for any help or thoughts.
New Demo Of Z-Ground Out-100% Code
This demo of myZ-Ground was half-finished about a month ago. I want to make it better but too busy recently. I decide to share it first, all sources will go public sooner or later.
The biggest difference this demo from the old one is this swf is created by pure code. The textures of cloud and sea are created by my texture generator engine-a small tool to generate all kinds of textures using perlin noise.
DEMO:HERE
CODE:UNDER OPTIMIZATION
Z-Ground:HERE
Z-Ground Terrain Demo
This demo was to test my way of rendering terrain in z-ground engine.
The result is not very satisfactory but at least it prove that my way works!
But after some optimazation it will be usable, I think.
It looks like some kind of voxel rendering effect but actually not.
(I also write one 3D Voxel Terrain engine using as3.0, if you are interested, here it is(with code))
Again, this swf was created by pure code, the textures were generated by my texture generator engine.
By the way, my next demo, which is almost done, is about lighting and shadow, water reflection effect of z-ground engine.
Demo:HERE(arraow key to move)
(BE CAREFUL!It needs lots of time for pre-rendering,to avoid crashing you computer,download it and use a flash player to view )
Ground Code Needed
Well, basically i need to make my game so my mc doesnt fall through the ground when he jumps or walks, coz so far all he does is jump, then fall through the floor. Does anyone have a code for a way to fix this, or advice on how to do it?
Flash Game Ground
Hi all. I''ve been creating a flash game for the last couple of weeks and have most of the code sorted out. I'm now at the stage of putting in the graphics.
Can anyone help me with the ground. Basically my game is a car race. The car static and the ground scrolls from right to left under the car.. currently i have the ground as a solid shape in flash, and i want to create some detail on it. what would be the best way to do this. i was thinking a jpg but that would be way to big..
Any one got any ideas or examples???
Thanks very much for any ideas at all. Even if its just a point in the right direction.
Cheers
Making A Ground? Collision Help
im making a 2d game with platforms and walls and floors and such, i've got most of the physics i need. gravity, speed, ect. But when he is supposed to stop after "hitting the ground he just goes straight thru. The ground he should stop at is a mc called bg and inside is a mc called platform. what am i doing wrong?
Code:
onClipEvent(enterFrame){
//Keeps Character from going thru the floor, roof & walls
if(this.hitTest(_root.bg.platform)==true
gravity = 0;
}
How Do Tile Back Ground Image
In flash Mx ...I was wonder if anyone knows if there is a way or if I can make a 800x100 background tiled like it does in html?? Is there a script???
How Do Tile Back Ground Image
In flash Mx ...I was wonder if anyone knows if there is a way or if I can make a 800x100 background tiled like it does in html?? Is there a script???
Back Ground In Html And Flash
I want to have my html back ground blend in with my flash one.
See i have this image and i want to get it centered and lined up with my flash movie.
Scrolling Or Looping Back Ground
does anyone here has a tutorial or know how to make a scrolling background. i mean like a loony toons like thing where it looks like the guy is moving against a background that just loops over and over
Switching Back Ground Picture
i saw a neet affect it was not a flash but just html
the backgound image switched
does anyone have a code for this?
faith
Making The Back Ground Scroll
Im new here and hope Ill be able to get help for a game I am making. I am trying to design an isometric game in wich the background will scroll when you get close to the edge of the screen. How would I go about doing this? Also, please tell me if this is in the right part of the forum. It didnt seem like too much of a newbie question so I went to general.
Player Walking On Uneven Ground?
I've seen this done in many games though am unable to find a tutorial on the best way of doing it.
I'd like to know how to make a player (sidescroller) walk on on uneven ground.
If someone could point me in the direction of a tutorial or give some tips that would be great.
Gravity And Irregular Ground Shape.
might be fairly basic, but i dont know where to begin. So i've got a ball, and its got actionscript for it to fall at a normal gravity effect, and its got bounce scripted into it as well when it reaches a y axis value of 400.
Since i've got that scripting pretty much figured out i want to go a step further and have it land on a non-level irregular shaped surface. Say, for instance, a valley shaped movieclip. I don't want it to hit the movieclip using hitTest and have it bounce straight back up from the spot it hit, but make it more realistic and have the ball bounce based on the slant and have it roll towards the middle like a ball hypothetically would.
Its one of those things where i know what i want to happen, i have an idea about how to do it, i dont know where to start. Thanks
Suggestions On How To Make Ground Work
what do you guys suggest when making the ground in a flash game.
i'm using a "gravity" variable and hitTest to simulate jumping and falling and all that
but i cant make multiple levels of terrain without rewriting the script for that piece of ground
help?
Racing Game Using A Seperate Mc For The Ground
I am trying to make a racing game with an overhead view looking down. There will be a seperate mc for the ground and another seperate mc for the players car. How can I do this? O ya and just in case your thinking the way I did: I already tried to "_rotate" the ground but when the car moves down the ground it moves away from the registration point, so therefore it rotates non relative to the car (like the car is skidding sideways).
Any help would be greatly appreachiated, thanx.
How To Detect Angle Of The Ground Underneath You?
I'm working on a game where you play as a ball thing rolling around levels, but I'm having trouble with the rolling physics.
I'm trying to have it so that if you're going up a slope, pressing right makes you go faster in the direction of the slope. so if I'm going up a 45 degree hill, and holding right, I'm going up and right, where as if I was going across a flat plain, all the force would just be going into going right.
I don't know any practical way to detect the angle of the slope underneath you, however, so if anyone can help, that would be very much appreciated.
Remove The Back Ground Color.
Good day all! Can anyone help with this little problem?
I'm adding a flash button to Dreamweaver. No problem! But!! The background image that the flash button sits upon has a gradient fill. And I want there to be no background color on the flash button. So I dont see a white or any other color behind the flash button!
Thank's all!
Changing B/ground Colour At Runtime
Hi,
I was wondering if anyone knew how to let a user change the background colour of the flash movie during runtime by clicking a button? I need to make something like the things you see on the accessible sites.
I have tried using movie clipsthat are not visible then making them visible whne they click a button, but as I have more then one scene this is not ideal as the background on the other scenes do not change.
thanks in advance,
Mitesh
Reference To 'stage.ground' Not Working- AS3
Alright, so i am having trouble with my class. it keeps kicking back this error:
1119: Access of possibly undefined property ground through a reference with static type flash.display:DisplayObjectContainer.
it's because "parent.ground" doesn't exist or something...
this is the script:
package {
import flash.display.*;
import flash.events.*;
public class Base extends MovieClip {
public static var cName:String;
public var speed:Number = 3;
private var grav:Number = 3, grounded:Boolean = false;
public function Base():void {
trace("Main Game Base Has Started...");
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKey);
this.addEventListener(Event.ENTER_FRAME, main);
}
public function checkKey(event:KeyboardEvent):void {
if (event.keyCode == 39) {
this.x+=speed;
}
if (event.keyCode == 37) {
this.x-=speed;
}
}
public function main(event:Event):void {
this.y += grav;
if (grounded) {
grav = 0;
} else {
grav++;
}
while (this.hitTestObject(parent.ground)){
grounded = false;
}
}
}
}
Reference To 'stage.ground' Not Working- AS3
Alright, so i am having trouble with my class. it keeps kicking back this error:
1119: Access of possibly undefined property ground through a reference with static type flash.display:DisplayObjectContainer.
it's because "parent.ground" doesn't exist or something...
this is the script:
package {
import flash.display.*;
import flash.events.*;
public class Base extends MovieClip {
public static var cName:String;
public var speed:Number = 3;
private var grav:Number = 3, grounded:Boolean = false;
public function Base():void {
trace("Main Game Base Has Started...");
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKey);
this.addEventListener(Event.ENTER_FRAME, main);
}
public function checkKey(event:KeyboardEvent):void {
if (event.keyCode == 39) {
this.x+=speed;
}
if (event.keyCode == 37) {
this.x-=speed;
}
}
public function main(event:Event):void {
this.y += grav;
if (grounded) {
grav = 0;
} else {
grav++;
}
while (this.hitTestObject(parent.ground)){
grounded = false;
}
}
}
}
Shoot Holes In Back Ground
Hi
Can someone please help me? I have a sniper scope crosshairs for my mouse cursor.... I want to leave bullet holes on the wall wherever you click down with your mouse. I know it is possible, I just need some help from a flash guru..lol
Thank you for reading this
Back in Black
www.team-atf.tk
Back Ground Music In Intro
I am constructing an intro for a game based website.
Everything works perfect flash wise, untill i apply the sound file into the background. I created a new layer, and just did the drag and drop from the library. When i publish it, the quality of the sound file goes to ****. Is there any way to fix this problem?
(the sound file is a song, .mp3 format)
~~ APsychoOne@hotmail.com ~~
~~ APsychoOne@aol.com ~~
Scrolling Or Looping Back Ground
does anyone here has a tutorial or know how to make a scrolling background. i mean like a loony toons like thing where it looks like the guy is moving against a background that just loops over and over
|