HitTest In Game
yeah so my game has a movie clip with the instance name "map", and this map is moved around by the key controls A, S, W, and D... the map is moved around while the character (with the instance name "character") stays in the center of the stage/screen, giving the illusion that the character is actually moving... around the perimeter of the map I have walls that enclose the area and I don't want the movie clip of the character to be able to go through those walls... i tried many different ways of getting the hittest to work and it just won't be freindly to me... Can anyone help?
Remember the character is not being moved the map is, and the walls MC is inside the map MC so that they both move together... Thanks all!!!
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-11-2006, 10:11 PM
View Complete Forum Thread with Replies
Sponsored Links:
Car Game Using HitTest
Hello all
I am making a car game and am using hitTest to do the collision detection for a few buildings. The problem I am having is that as the car MC rotates (when you turn) its starts to return inaccurate values for the hieght and width so that the collision detection gets pretty ropey (its at its worst at 45 degrees). I was wanting to know if anyone knows of any better techniques to improve the collision detection.
I know that there are two ways of using hitTest, at the moment I am using:
Car.hitTest(Object);
But there is a method that I don't understand how to use that goes more like this:
Car.hitTest(x, y, Boolean);
Maybe this could be used??
Once I have got the game working I will post a link on Flashkit.
Cheers
Mark
View Replies !
View Related
Hittest For Game MX
I've been working on this one part of my short game in which dynamic text tells how many times the ball has hit a certain movieclip on the stage. I just can't get it to work. I've consulted tutorials, help in flash, and I can't figure it out. I sent my fla with this letter. Could someone please take a look and try to help? If you find the problem could you fix it? I have no idea. The actionscript I'm mainly having trouble with is hittest, target paths and dynamic text. Please someone! I'm quite new at this.
If you can't be bothered downloading it, then heres the situation. I'm getting some dynamic text to tell how many times you've hit a ball. I figure the only way is to use
if(this.hittest(_root.ball));
_root.p1=_rootp1+1
Telltarget(_root.ball)
Play;
p1 is the var for the dynamic text box, all the actionscript is under the actions for the bat that hits the ball, and _roor.ball is the target path for the ball.
It dosen't seem to work. I also write a few frames earlier that _root.p1=0
If you can help me from all that, please do, but please download the fla. to get a better look. (I probably made a typo somewhere)
View Replies !
View Related
HitTest In A Game
I'm curently on a project of making an rpg game with flash, ok, I'm not really far, but my guy has his movements and all, then I enter the part where I use the hitTest. My code ressembles to this, I don't know if that is what I have to do but anyways:
on (keyPress "<Left>") {
_root.bonhomme._rotation = -90;
_root.bonhomme._x = bonhomme._x-4;
_root.bonhomme.nextFrame();
if (_root.bonhomme.hitTest(wall1)) {
_root.bonhomme._x = _root.bonhomme._x+4.5
}
}
on (keyPress "<Right>") {
_root.bonhomme._rotation = 90;
_root.bonhomme._x = bonhomme._x+4;
_root.bonhomme.nextFrame();
if (_root.bonhomme.hitTest(wall1)) {
_root.bonhomme._x = _root.bonhomme._x-4.5
}
}
on (keyPress "<Down>") {
_root.bonhomme._rotation = 180;
_root.bonhomme._y = bonhomme._y+4;
_root.bonhomme.nextFrame();
if (_root.bonhomme.hitTest(wall1)) {
_root.bonhomme._y = _root.bonhomme._y-4.5
}
}
on (keyPress "<Up>") {
_root.bonhomme._rotation = 0;
_root.bonhomme._y = bonhomme._y-4;
_root.bonhomme.nextFrame();
if (_root.bonhomme.hitTest(wall1)) {
_root.bonhomme._y = _root.bonhomme._y+4.5
}
}
ok now, bonhomme is a moviw clip of a guy walking from an air view. Wall 1 is just a sqare, so the problem is that I don't know what to do if I want to make a lot of walls, will I have to make a hitTest for each walls in the game, like 100 times this, coz you can't name two things wall1. If I'm not clear, feel free to ask questions.
View Replies !
View Related
Hittest Help On Game.
Im working on a game. When you hold left a guy starts flying and flaps his hands until you let go and then he just falls and doesnt flap them.
If you hit the white dot it takes you to another frame saying you lose. What I want it to do is when he his the dot he needs to change into like blood or something and fall down. I cant figure out how to do it.
This is the code
Code:
onClipEvent (enterFrame) {
if (this.hitTest(_root.balloon)) {
_root.life -= 1;
if (_root.life == 0) {
_root.gotoAndStop(5);
}
}
}
I know I have to change this line here. But I have no idea what.
Code:
_root.gotoAndStop(5);
Can you make it where it replaces the guy with another movie clip.
Take a look at the fla to learn more.
http://drakeshangout.com/Flight4.fla
Here is the swf
http://leovilletownsquare.com/incomi...501-flight.swf
View Replies !
View Related
Hittest Game Help
Hi,
I’m trying to make it so that the Main character of this game (Hero root) will interact with the falling snowflakes and essentially eat them.
The snowflakes are movie clips (Fall). I just want to make it so that when the character collides with a snowflake it will disappear. I also have to add a score keeper that would tally the snowflakes eaten.
Any help would be greatly appreciated or a point in the direction of a good tutorial to achieve this. I’ve attached the file in case anyone can see a problem I would have doing this the way I set the file up.
Thanks in advance
Brett
View Replies !
View Related
HitTest On My Game.
I decided to make a game, you can see what ive got so far : www.evolewtion.co.uk/space_station.html
Dont worry about the intro screen or instructions just yet.
(But if you dont know : a = Move left, d = Move right, Mouse = Aim, Mouse Click = Shoot)
So I have the tank, and the falling bomb.. I want it to explode if I hit it.. I have an explosion already made and this is the code I am using (Yet nothing happens?)
Code:
if (bullet.hitTest(_root.bomb_drop)){
with (_root.bomb_drop.bomb){
gotoAndPlay("blow-up");
}
}
If anyone truly beleives they can fix it if they have the .fla post here, and I will PM you the link.
I would like to keep the game as much as mine as possible for the moment..
Thanks.
View Replies !
View Related
Game HitTest Problem
Hi
I'm still quite new at actionscripting, and am trying to learn by building a simple game. The idea is that the user can create simple drawings by moving tetrus like shapes around the screen.
I would like to make it impossible to move the shapes over one another, probably with hitTest. But can't get it right!
I get as far as shape 1 not moving over shape 2, but when you add another shape, it merrily does whatever it pleases.
Does anyone have time to take a look?
Thanks!
View Replies !
View Related
HitTest Problem In Car Game
Please take a look at the source: http://www.thelivid.com/cargame2.fla
the actions i'm having problems with are 2/3 down the actions on the "car".
the problem is that the car drives into the wall, and the hittest only checks the centre of the car movieclip. i want the car to bounce when any part of it hits the walls. i've tried to get help from various flash chatrooms and no-one seems to know what's wrong.
can anyone spot the problem, or suggest how it can be fixed?
cheers
View Replies !
View Related
Game[as1]problem With HitTest
Hi there, i have a problem with my game.
Its in this url:
skidWRX
When i do reverse speed, in the walls direction, the car gets stuck.
So if you can take a look at the file downloading it in the url.
Thanks for now.
Marcelo
View Replies !
View Related
Game Hittest Problem
okay. I have a small gamelet. in it i have a floor "floor" that works perfectly. I'm standing on it right; not too high; not too low. in the same mc I have a platform "plat1". To get on it I have to jump as high as possible, and I only can stand on it sometimes. Also when I jump again I drop through it. here is my code on my main guy "hero"
Code:
onClipEvent (load) {
maxjump = 6;
gravity = 25;
}
onClipEvent (enterFrame) {
if (_root.floor.hitTest(_x, _y, true) or (_root.floor.plat.hitTest(_x, _y, true))) {
air = false;
} else {
air = true;
}
if (air == true) {
this._y += 25;
}
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(2);
_root.floor._x -= 6;
dir = 1;
} else if (Key.isDown(Key.LEFT)) {
this.gotoAndStop(4);
_root.floor._x += 6;
dir = 2;
}
if (Key.isDown(Key.UP) && jump == true) {
_y -= jumpSpeed;
}
if (air == false) {
jump = true;
jumpcount = 0;
jumpSpeed = 32;
}
if (Key.isDown(Key.UP)) {
jumpcount += 1;
}
if (jumpcount>maxjump && jumpSpeed>-2) {
jumpSpeed -= 2;
}
}
also here is my fla.
View Replies !
View Related
Hittest Problem For Car Game
onClipEvent (enterFrame) {
// make the car go forward
if (Key.isDown(Key.UP)) {
speed += 1;
}
// make the car go backwards
if (Key.isDown(Key.DOWN)) {
speed -= 1;
}
// tells the car to slow down after the speed of 20
if (Math.abs(speed)>5) {
speed *= .7;
}
// you can change the rotation of the car to your desire
if (Key.isDown(Key.LEFT)) {
_rotation -= 7;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 7;
}
// here is where the hittest is for the boundary
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.1;
}
}
I want it so I can use multiple "Land" Boundries. This code only lets me bounce back from one of the objects with the instance name of Land.
I need help with this so I will be greatly thankful
View Replies !
View Related
HitTest For Game Not Working
Here it is in action:
http://www.philosophyzero.com/hittest.swf
See how it screws up on the part that sticks out?
This is the code:
Code:
onEnterFrame = function(){
_root.hit();
_root.move();
}
function hit() {
with(_root.box) {
if (_root.wall.hitTest(getBounds(_root).xMax, _y, true)) {
_root.wall._x += 1;
}
if (_root.wall.hitTest(getBounds(_root).xMin, _y, true)) {
_root.wall._x -= 1;
}
if (_root.wall.hitTest(_x, getBounds(_root).yMax, true)) {
_root.wall._y += 1;
}
if (_root.wall.hitTest(_x, getBounds(_root).yMin, true)) {
_root.wall._y -= 1;
}
}
}
//scrolling
function move() {
if (Key.isDown(Key.DOWN)) {
wall._y -= 1;
}
else if (Key.isDown(Key.UP)) {
wall._y += 1;
}
else if (Key.isDown(Key.LEFT)) {
wall._x += 1;
}
else if (Key.isDown(Key.RIGHT)) {
wall._x -= 1;
}
}
Real simple, huh? But I can't for the life of me figure out how to perfect it.
View Replies !
View Related
[FMX,AS2] Game Help - Hittest And Distance
actionscript help in game
i am working on a game called "virus".
you click somewhere on the screen and the virus goes to where you click.
you have to dodge random moving white blood cells, and if you hit them you lose. everything is working. except for one thing.
scoring.
i have made a movieclip with a dynamic textbox in (score), and in the movie clip there is a section where the number in the score textbox goes up really quickly, a section where is goes up medium, and a section where it goes up slowly.
i want to make it so that when you get closer to the center of the movie, for the score to go up quicly, and slower as you get further out.
i have tried hittest with movie clips in the centre of the stage, but it doesnt seem to work.
i have flash mx 2004.
help very much appreciated. thanks a lot in advance!
View Replies !
View Related
Game- HitTest Problem
Ive have made a few maze games with enemies that have to be avoided and it has all worked fine but my new project is a 2 player game where both players have to avoid multiple enemies inside an area. i made the enemy run on a guide but the players kept on dying in places where the enemy was not so i got rid of the guide and made the enemy move frame by frame, the problem still occured.
I have attached the files, i have drawn the guide aswell to show where the enemy goes.
Player1 Controls = Up, Down, Left, Right Arrows
Player2 Controls = W, S, A, D
(If you do not move player2 you will notice that he is killed without being touched.)
Please look at the .fla for the coding. (all the coding is inside the maze MC)
Thank You
View Replies !
View Related
HitTest (game Developing)
Me and a friend are making a game in actionscript 3. It's a typical horizontally-scrolling spaceshooter, only with a viking theme.
We are having some trouble getting the enemies to disappear when they are hit by the dragon's fireballs (yes, we have a dragon AND fireballs). The event that occurs when the collision happens resides in the enemy-class file.
What is the best way to resolve our problem?
Here is the code for the collision-detection in the enemy-class:
(Keep in mind that we are completely new to actionscript and that this is our first as project).
Code:
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class Fiende1 extends BalderSpill {
public function Fiende1() {
this.scaleX=.7;
this.scaleY=.7;
this.addEventListener(Event.ENTER_FRAME, beveg);
this.addEventListener(Event.ENTER_FRAME, checkCollision);
}
private function beveg(event:Event) {
this.x-= 15;
}
public function checkCollision(event:Event) {
if (drage_mc.hitTestObject(this)) {
this.removeChild(this);
}
}
}
}
View Replies !
View Related
HELP HitTest In Actionscript Game
Hi all. I'm quite a Noob to Flash, and actionscript, and have recently been asked to develop an educational game. I looked at a fall and catch game, which encorporates multiplication and numbers in the game.
However i am having a little trouble with the hit test. I have a movie clip of the item 'num', which is added every 45 frames, and is animated to drop.
I have a character which is called char_mc which is movable (left and right) with the keyboard.
I have This code for the hitTest, and have tried putting this in different parts of the script too.
Code:
if(this.hitTest(_root.char_mc)) {//Hit test to see if the new drop hits the charactor (i.e user has caught the item)
score +=1;//increment the score by 1 if it does hit
trace("hit");//output the message hit if it's a hit
}
else //else decrese the score by one
{
score -=1;
}
I can post code up and even the FLA if required.
I'm sorry if i'm being a bit vague but hopefully someone can help me. Thanks in advanced
View Replies !
View Related
[FMX,AS2] Game Help - Hittest And Distance
actionscript help in game
i am working on a game called "virus".
you click somewhere on the screen and the virus goes to where you click.
you have to dodge random moving white blood cells, and if you hit them you lose. everything is working. except for one thing.
scoring.
i have made a movieclip with a dynamic textbox in (score), and in the movie clip there is a section where the number in the score textbox goes up really quickly, a section where is goes up medium, and a section where it goes up slowly.
i want to make it so that when you get closer to the center of the movie, for the score to go up quicly, and slower as you get further out.
i have tried hittest with movie clips in the centre of the stage, but it doesnt seem to work.
i have flash mx 2004.
help very much appreciated. thanks a lot in advance!
View Replies !
View Related
Game[as1] Problem With The HitTest
Hi there, I want to know if somebody here could help me.
In this url:
skidwrx
I have a game.
So in this game have crounchers that the car cant pass through.
But when I do reverse speed and go to the crounchers the car gets stuck.
So anybody could help to solve this problem?
Many Thanks
marcelozep
View Replies !
View Related
[as1] Or [as2] Doing A Game, Guess Is HitTest
Hello there, i was searching for a real functional script for my game.
Its a tank game:
You are a tank, and you have an enemy. Another tank that tries to shoot on you. Theres an ambient, like limits on the stage, that the tank cant go through, like bars, squares, for a little dificult in the game.
My guess in the start was to get the maze script from flash samples, im talking about hitTest here. In the maze game, the square cant go through the limits as my game, but, it didnt work. What happens is:
The tank pass through when it reachs the limits, like pressing two or more keys making a diagonal movement.
Please, if somebody can help me, will be great.
here is the link to the game project:
tank game
Many Thanks
View Replies !
View Related
Flash Game (hitTest Stuff)
I have a movie clip called "kyle" inside of "kyle" is "kyle_head" and "kyle_body". I need my crosshair (named "cross") to detect if it has hit the mc "kyle_head" or "kyle_body" the actions will be different for each detection but I dont know how to use the hitTest method very well and If some one could help me out I'd be very gratefull.
*If you post code, plz use comments.
View Replies !
View Related
Hittest() Maze Game Trouble
Hi all,
first thanx for looking at my thread, i've had a lot of trouble looking through loads of sites for an awnser to my problem. any way, here it is:
i have made a little maze game where you ave to direct a ball using the arrow keys round the maze without touching the walls. i have 4 frames:
1] the main page (title page)
2] the actual game.
3] the "you lose" page (click here to play again...)
4] the you win page
the buttons are working fine (click here to play again, instructions...) but to get to the win and lose pages it needs to realise that the ball has made contact with the "end" (a pad) to go to you win or contact wit one of the walls to go to you lose.
the balls instence name is "fly", the walls instence name is "walls" and the end pads instence name is "pad"
please help me with this problem, i have hardly any knolege of actionscript but i'm hoping to make it better
View Replies !
View Related
Starfield Style HitTest Game
Hey, I'm having trouble making a game, and I cant seem to get something working. Here is what I have so far:
http://school.timswildwackyemporium....st/candy1.html
As you can see, When you play Once you catch the stars, they disappear.
As a result, the highest score you can get is one hundred.
I would like to make it so that rather than just delete the movieclip, I can movie it back into the beginning of the starfield.
I did not write the code for the starfield, which is why I'm having such trouble figuring this out.
Heres my code
ON THE FRAME
Code:
stop();
score = 0 ;
_root.attachMovie("count_down", "count_down", 12000, {_x:20, _y:330});
_root.attachMovie("hero", "hero_on_stage", 10000,{_x:200,_y:20});
_root.attachMovie("trail_sprite", "trail_mc", 8000);
trailbitmap = new flash.display.BitmapData(500, 350, true,0x000000);
_root.createEmptyMovieClip("trail", 1);
trail.attachBitmap(trailbitmap, 0);
trail_mc._visible = false;
hero_on_stage._visible = false;
power = .65;
yspeed = 0;
xspeed = 0;
wind = 0.00;
gravity = 0;
upconstant = 0.75;
friction = 0.99;
start_time = getTimer();
countdown = 30000;
hero_on_stage.onEnterFrame = function() {
elapsed_time = getTimer()-start_time;
_root.count_down.time_left.text = time_to_string(_root.countdown-elapsed_time);
if (elapsed_time >= countdown) {
_root.gotoAndStop(5);
_root.count_down.removeMovieClip();
};
if (Key.isDown(Key.LEFT)) {
xspeed = xspeed-power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed = xspeed+power;
}
if (Key.isDown(Key.UP)) {
yspeed = yspeed-power*upconstant;
}
if (Key.isDown(Key.DOWN)) {
yspeed = yspeed+power*upconstant;
}
xspeed = (xspeed+wind)*friction;
yspeed = yspeed+gravity;
if (xspeed>15) {
xspeed = 15;
}
if (xspeed<-15) {
xspeed = -15;
}
if (yspeed>15) {
yspeed = 15;
}
if (yspeed<-15) {
yspeed = -15;
}
this._y += yspeed;
this._x += xspeed;
if (this._x<0) {
this._x += 500;
}
if (this._y<0) {
this._y += 350;
}
if (this._y>350) {
this._y -= 350;
}
if (this._x>500) {
this._x -= 500;
}
_root.trail_mc.trail_sprite._x = this._x;
_root.trail_mc.trail_sprite._y = this._y;
_root.trailbitmap.draw(_root.trail_mc);
trail_rectangle = new flash.geom.Rectangle(0, 0, 500, 350);
trail_blur = new flash.filters.BlurFilter(2, 2, 3);
_root.trailbitmap.applyFilter(_root.trailbitmap, trail_rectangle, new Point(0, 0), trail_blur);
};
MovieClip.prototype.placeInSpace = function(id) {
var ratio = this.focaldistance / Math.sqrt(this[id].z * this[id].z);
this[id]._x = this[id].x * ratio;
this[id]._y = this[id].y * ratio;
this[id]._xscale = this[id]._yscale = 1000 / this[id].z;
if (this[id].hitTest(hero_on_stage)){
_root.score ++;
this[id].swapDepths(10000);
this[id].removeMovieClip();
}
}
MovieClip.prototype.randomPlace = function(id) {
var radius = this.rmin + (this.rmax - this.rmin) * Math.random();
var polar = 2 * Math.PI * Math.random();
this[id].x = radius * Math.cos(polar);
this[id].y = radius * Math.sin(polar);
this[id].z = this.zmin + (this.zmax - this.zmin) * Math.random();
if (this[id].hitTest(hero_on_stage)){
_root.score ++;
this[id].removeMovieClip();
}
}
function time_to_string(time_to_convert) {
elapsed_hours = Math.floor(time_to_convert/3600000);
remaining = time_to_convert-(elapsed_hours*3600000);
elapsed_minutes = Math.floor(remaining/60000);
remaining = remaining-(elapsed_minutes*60000);
elapsed_seconds = Math.floor(remaining/1000);
remaining = remaining-(elapsed_seconds*1000);
elapsed_fs = Math.floor(remaining/10);
if (elapsed_hours<10) {
hours = "0"+elapsed_hours.toString();
} else {
hours = elapsed_hours.toString();
}
if (elapsed_minutes<10) {
minutes = "0"+elapsed_minutes.toString();
} else {
minutes = elapsed_minutes.toString();
}
if (elapsed_seconds<10) {
seconds = "0"+elapsed_seconds.toString();
} else {
seconds = elapsed_seconds.toString();
}
if (elapsed_fs<10) {
hundredths = "0"+elapsed_fs.toString();
} else {
hundredths = elapsed_fs.toString();
}
return minutes+":"+seconds+":"+hundredths;
}
ON FIELD MOVIECLIP
Code:
onClipEvent (load) {
this.count = 100;
this.speed = 3;
this.focaldistance = 25;
this.rmin = 50;
this.rmax = 1000;
this.zmin = 10;
this.zmax = 300;
for(var i = 0; i < this.count; i++) this.attachMovie("dot", i, i);
}
onClipEvent (enterFrame) {
for(var i = 0; i < this.count; i++) {
if((this[i].z -= this.speed) <= 0) this.randomPlace(i);
this.placeInSpace(i);
}
View Replies !
View Related
OnEnterFrame/hitTest - Game Scoring
I am designing a game for a client that is very basic. A kayaker will kayak down the river avoiding rocks and other objects. For each second he paddles, he receives a point. When he hits an object points stop, as does the river's motion, until the user moves the kayaker from the object.
I have everything figured out except I want the game to be over after the user has crashed 5 times. I have a countdown counter (bottom left corner) built, but when the kayak collides with another object, the counter begins rapidly decreasing. I believe this is because it is looping with the onEnterFrame method, but I do not know how to make it just decrease by one (1) each time there is a collision. I have tried deleting the onEnterFrame when a collision happens, but I do not know how to get the function back after the kayak moves away from the object.
I hope this makes sense.
The SWF can be seen here:
http://www.bullpencatcher.com/rivergame3.swf
And my FLA can be downloaded here:
http://www.bullpencatcher.com/rivergame3.fla
The game is very basic right now with only one object and the banks of the river that will stop the flow and cause the countdown to start. Use the left and right arrows to steer.
Any advice you could give would be greatly appreciated. Let me know if you need more info.
Bryan
View Replies !
View Related
HITTEST HELP COLLSION HELP My Simple Game
I have a simple question I created a basic game that when the laser hits the box it invokes the target to play. My lasers are duplicate movieclips.I have used this script in frame 1 main time line this is where the problem is I think:
if ("laser" + i.hittest(box)) {
tellTarget ("hit") {
play();
}
}
And in frame 2
gotoAndPlay(1);
To complete a loop. The lasers are fired from a simple button like this
on (press) {
i = i + 1;
duplicateMovieClip(laser, "laser" + i, i);
setProperty("laser" + i, _x, getProperty(fire_btn,_x));
setProperty("laser" + i, _y, getProperty(fire_btn,_y));
}
hit >>>> is the target I want to play when the laser duplicates are fired
this method works well if the moviclips are not duplicated. Is my pathing wrong can anyone help me make the target (hit) play when the "laser" + i hittest the movieclip box.
View Replies !
View Related
HitTest Penalty Kick Game
I stopped writing actionscript for about a year now as my job had nothing to do with it...but now I'd like to get back in for fun. I'd like to make a simple penalty kick game where when you move the keyboard that shows where you can kick it (i know how to do this)...And when you kick it have the ball be animated towards where you kick it (i don't know how to do this)...and if the goalkeeper is nearby, he will stop it (i don't know how to do this).
Any places I can start looking? Or any help you can give?
View Replies !
View Related
AS Intermediate Needs Master For HitTest + Score Game
I have activity levels within an MX game which are using "hitTest" to score at activity level, which when a certain score is achieved, will add +1 to the overall game score.
Problems are: 1) working multiple drag MC's using "hitTest" on the same stage doesn't seem to work - it will only let me choose the first drag MC
2) Once the "stopDrag" is invoked I then need the player to go and click a check answers button to add the "true" statements returned from the target areas. But the moment the mouse rolls away from the target area, the status becomes "false" again.
Appreciate anyone taking a look at the fla and making suggestions as to how this might be achieved easier or more efficiently
http://www.sprint.net.au/~dman/hitTest-test.fla
dman
View Replies !
View Related
Problems Using HitTest In My Simple Flash Game
So I am trying to get my blaster movie clips to hitTest correctly against my enemy movie clips.
When I press the space bar, I run this code from my player movie clip:
blastCount++;
_root.blast.duplicateMovieClip("blast"+blastCount, blastCount);
_root["blast"+blastCount]._visible = true;
This will attach my blast movie clip, which has it's own movement information, and thus zips across the screen just f ine.
I am also creating enemy movie clips at random y positions with the following code:
viruscount++;
_root.virus.duplicateMovieClip("virus"+viruscount, viruscount);
_root["virus"+viruscount]._visible = true;
These of course have their own movement info, and work just fine as well.
The problem comes when I want to hitTest these two objects against one another. I am constantly adding more blasts and more enemies, so I'm not exactly sure how I can test these against each other given that there isn't just 2 objects, but many of them, with varying names (blast1, virus7, etc). I was thinking about using some sort of array to store names and check against each other, but I am still a bit lost...
Any help would be greatly appreciated!
View Replies !
View Related
Help Needed With A Game I Am Making--Its About HitTest/duplicateMovieClip
Hello...
I'm making a game with lots and lots of the same movie clips and I don't want to give thousands of items the same actionscript. So logically I thought I should use actions on frames (makes sense...to me at least) but when I used that, nothing happened. can anyone explain what went wrong/how to fix it? I only need a little help. Heres the description:
I have a guy that when he hits a coin, the coin needs to disappear (I will use removeMovieClip later, but for now I want this) and change the dynamic text box to +1. The var name for the text box is "_root.money". The instance name of the coin(s) is "coin_mc". I put this code on the frame:
money = 00;
if (_root.guy.hitTest (_root.coin_mc)) {
_root.money++;
_root.coin_mc._x = -50;
_root.coin_mc._y = -50;
}
I know changing the x & y is "cheating", but this is temporary. thank you for helping if you reply. Posting your name/answer to my problem will earn you a place in the credits of the game!!!! (if it works)
PS-- I am currently toying with the code to get it to work.
View Replies !
View Related
Code Review For Simple Game Using HitTest
Hi everyone,
I have created a simple game using flash 8 ASv2.
all the code is on frame one of the movie.
right not it looks very messy.
is there a way i could make this look tighter and cleaner.
I tried using arrays and a switch case, but since i am not very familiar with them it only messed up the code more,
Thank you for your time and help.
the code is here
Code:
stop();
makeFinalPipeInvisible();
this.onEnterFrame = function():Void{
checkPipePlacement();
}
//start dragging pipe peice 01
this.pipe01_mc.onPress = function():Void {
trace("it");
startDrag(this);
}
this.pipe01_mc.onRelease = function():Void {
this.stopDrag();
}
//start dragging pipe piece 01
this.pipe01_mc.onPress = function():Void {
trace("1");
startDrag(this);
}
this.pipe01_mc.onRelease = function():Void {
this.stopDrag();
}
//start dragging pipe peice 02
this.pipe02_mc.onPress = function():Void {
trace("2");
startDrag(this);
}
this.pipe02_mc.onRelease = function():Void {
this.stopDrag();
}
//start dragging pipe peice 09
this.pipe09_mc.onPress = function():Void {
startDrag(this);
}
this.pipe09_mc.onRelease = function():Void {
this.stopDrag();
}
//Functions start here ***
//This one sets the initial final pipe to invisible
function makeFinalPipeInvisible():Void{
this.finpipe01_mc._visible = false;
this.finpipe02_mc._visible = false;
this.finpipe03_mc._visible = false;
this.finpipe04_mc._visible = false;
this.finpipe05_mc._visible = false;
this.finpipe06_mc._visible = false;
this.finpipe07_mc._visible = false;
this.finpipe08_mc._visible = false;
this.finpipe09_mc._visible = false;
}
//Checks for hit test and makes final piece visible
function checkPipePlacement():Void {
if (this.pipe01_mc.hitTest(this.finpipe01_mc)){
this.finpipe01_mc._visible = true;
this.pipe01_mc._visible = false;
}else if (this.pipe02_mc.hitTest(this.finpipe02_mc)){
this.finpipe02_mc._visible = true;
this.pipe02_mc._visible = false;
}else if (this.pipe09_mc.hitTest(this.finpipe09_mc)){
this.finpipe09_mc._visible = true;
this.pipe09_mc._visible = false;
trace("game over");
}
}
the fla file can be found here.
View Replies !
View Related
Detecting A Hittest Within Tile Based Game
hi there, i hope someone can help me- i´ve been stuck with this for the last two days.
i have a function here, which loads a 2 dimensional array into a movieclip, attaches tiles with a linkage from 0 to 5 to the stage and does a "hittest" by chekcing the indizes of the array.
kinda like that:
ActionScript Code:
Character.prototype.checkWorld = function(vx, vy) {// checks the tiles around the character
return this.World.map[Math.round((this.PlayerY-this.World.gridsize/2*vy.sign())/this.World.gridsize)+vy][Math.round((this.PlayerX-this.World.gridsize/2*vx.sign())/this.World.gridsize)+vx];
};
Character.prototype.onAir = function() {
//checking the tile while the character is jumping
// go through a parable //
this.jPointer += this.jumpFreq;
this.PlayerY = this.ty+(this.jPointer*this.jPointer-this.jH2);
// checkWorld for stones //
if (this.checkWorld(0, -2) == 1 && this.jPointer<0) {
this.jPointer = -this.jPointer;
//check world for breakable stones
} else if (this.checkWorld(0, -2) == 5 && this.jPointer<0) {
trace(stonesDestroy)
//this.modus=3;
this.jPointer = -this.jPointer;
}
}
World.prototype.build = function() {
Object.registerClass("player"+select, Character);
var tile;
stonesDestroy = new Array();
//this is supposed to be the array for all the tiles which are breakable
for (var k = 0; k<this.map.length; k++) {
for (var i = 0; i<this.map[0].length; i++) {
if (this.map[k][i] == 9) {
var playerProperties = {_x:i*this.gridsize, _y:k*this.gridsize, playerX:i*this.gridsize, playerY:k*this.gridsize, modus:0, x:i, y:k, control:Usercontrol, jumpHeight:6, jumpFreq:.6, runSpeed:2, climbSpeed:1, World:this};
this.player = this.loc.attachMovie("player"+select, "player", this.map[0].length*this.map.length+1, playerProperties);
// first assigment to character //
this.player.onEnterFrame = this.player.FrameController;
this.map[k][i] = 0;
// free tile
}
this.loc.attachMovie("tile"+this.map[k][i], "tile"+k+"_"+i, num++, {_x:i*this.gridsize, _y:k*this.gridsize});
if (this.map[k][i] == 5) {//here i add all the breakable tiles to the array
stonesDestroy.push("tile"+k+"_"+i);
}
}
}
};
// World Data //
#include "mymap.as"
// Create JumpNRun Object //
JumpNRun = new World(scene, 16, map);
JumpNRun.build();
stop();
but i just cant get to know, which of the tile of the stonesDestroy is hit - i can only trace the content of the array- i need to know because this certain tile is supposed to play an action.(f.e. tile_x_y.gotoAndStop(2))
how can i solve that?
thanks for your help, please ask, in case something isnt clear.
s.
View Replies !
View Related
Help With Tile-based Game With HitTest Collision/slopes
Hello all,
I have been tooling around with making a tile-based engine using a hitTest collision method, the main goal in using this for slopes of any kind on a tile.
I started with OOO's base 1st tutorial and spun off on my own, and have hit a snag. For the most part i have walking up hill working. I dont have gravity in place, so i hold down the down key as gravity. this allows me to walk down hill fine as well.
The problem im having seems to be some wierd flash math issues. As you will see in the attached FLA, the slopes work great, but react differently if you walk to the right versus the left. Currently, neither direction will actually allow you to walk up the slope of more than one tile. I seem to be missing a check in there somewhere. Also, youll notice that when walking to the left or right while holding down (which in a platformer would be gravity) the character seems to dip or stutter at the joining line between any two tiles. Two further illustrate what i think is the problem with that, the character can actually pass through two tiles if you hold down alone in between the two. This can be done easily between columns 5 and 6. but the collision boxes are in theory touching, so i dont see how this is possible.
Any help anyone can give would be great. And sorry if this makes no sense, i can try and explain better if need be.
Thanks!!!!!
View Replies !
View Related
Hello Game Help Please, I Need A Hittest Code For Objects For Character To Walk On
Thank god for this newbie forum, I was using another site that didn't have one, and didn't get much help.
I'm making a platform game ( not with tiles) and I want to make objects that the character can't walk through. Like stairs, that it can walk up and down. Or a block to jump on.
I need simple actionscript code for an object, so the character doesn't walk through it and can walk on top of it. Please please help!
Also a way so if they stop in front of another character, and press 'g' or something, it goes to a frame where the character is talking. But I mainly need the objects thing.
(It's a side view game like the old mario ones)
If anyone knows how to make it side scrolling too?
This is the actionscript for the character( I used a open source fla from this site to make it, and I changed all the images to a different character) The code works, but I want to add some code to it to make it stop when it hits an object, and be able to walk on the object. Or code to add to the object itself.
onClipEvent (load) {
move = 0;
lock = true;
}
onClipEvent (keyDown) {
this.mario.play();
}
onClipEvent (keyUp) {
this.mario.gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (move == 0) {
if (lock) {
this._x += Xstep;
Ystep = 0;
Xstep = 0;
if (Key.isDown(Key.LEFT)) {
Xstep = -10;
Ystep = 0;
this.gotoAndStop("left");
} else if (Key.isDown(Key.RIGHT)) {
Xstep = 10;
Ystep = 0;
this.gotoAndStop("right");
}
}
}
}
onClipEvent (enterFrame) {
render();
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 4) == "coin") {
if (this.hitTest(_root[i])) {
_root[i].gotoAndStop(2);
_root.score += 1;
}
}
}
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 0) == "bad") {
if (this.hitTest(_root[i])) {
_root.lives -= 1;
if (_root.lives == 0) {
_root.gotoAndStop(2);
}
}
}
}
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 4) == "save") {
if (this.hitTest(_root[i])) {
_root[i].gotoAndStop(2);
_root.score += 10;
}
}
}
}
View Replies !
View Related
[MX04] HitTest Problems In Test Game. Tracing Hit When Not Hitting
Im having problem with hitTesting my movie.
Basicly here is the situation. I have my game.. (very simple at the moment.)
where my Background (mc_level) moves around my character (mc_character).
the mc_level moves correctly around my character.
However when it comes to the hittest, the level passes through the character,
and seems to glitch or something.
so i added a trace command and found its hitting when the mc_character is not over the mc_level. this happeneds mostly over the right side of the level.
Can anyone help me with this problem? i want it so that when mc_level contacts
mc_character it stops moving on in the direction of the collision.
here is what i have... ( i hope i attatched it right... )
View Replies !
View Related
Pong Game - HitTest/getBounds Advice & Guidance Needed
Hi,
Im a newbie to flash mx, developing a pong style game with a football theme.
I have three symbols a cpu footballer, football and the player footballer these all have registration points in the middle.
Footballers are located at top and bottom of the screen.
See my collision detection code below which is attached to the football movie clip (this code show what happens when the ball(this) collides with the cpu).
Code:
//if(this.hitTest(_root.cpu))
{
ang = (this._x-_root.cpu._x)/5; //roughtly calculate where on the CPU player it hit
this.xspeed += ang; //and use it as the rebound angle
this.yspeed = this.yspeed*-1;
}
Code:
this.yspeed = 3
Only when it rebounds of a wall or hits a player does it reverse a direction using the code
Code:
this.yspeed = this.yspeed*-1;
This code worked Intermittingly, however the ball can hit the layer or cpu from the side and generally caused issues due to the registration points.
Within the hit test code is executed t would revert the direction by setting yspeed to 3 or -3, however the 3pixels distance would not clear the collision hitTest area between man and ball, a loop would occur of yspeed being set to 3/-3, 3/-3, 3/-3 etc..,
I then read about getBound and tried the method below:-
Code:
getlimitscpu = _root.cpu.getBounds(_root);
if (this.hitTest(getlimitscpu.yMax,getlimitscpu.xMax,true))
// use the same code as above to change value of yspeed
I can provide the full source code if required, but can someone help in guiding me in the right direction to solve this issue?
Let me know if some of this doesnt make sense, I know its quite a long rant!
Thanks
Rob
View Replies !
View Related
[MX] Platform Game: Object Character Can Walk On+not Walk Through. Hittest?
I'm making an art-based ( hence me not minding where I get the code) game in Flash MX. (non tile, side view)
I need a bit of actionscript to add to the character/object so it can't walk throught the object, and can walk on it. To be applied to stairs, blocks, etc.
This is the actionscript for the character( I used a open source fla from this site to make it, and I changed all the images to a different character) The code works, but I want to add some code to it to make it stop when it hits an object, and be able to walk on the object. Or code to add to the object itself.
onClipEvent (load) {
move = 0;
lock = true;
}
onClipEvent (keyDown) {
this.mario.play();
}
onClipEvent (keyUp) {
this.mario.gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (move == 0) {
if (lock) {
this._x += Xstep;
Ystep = 0;
Xstep = 0;
if (Key.isDown(Key.LEFT)) {
Xstep = -10;
Ystep = 0;
this.gotoAndStop("left");
} else if (Key.isDown(Key.RIGHT)) {
Xstep = 10;
Ystep = 0;
this.gotoAndStop("right");
}
}
}
}
onClipEvent (enterFrame) {
render();
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 4) == "coin") {
if (this.hitTest(_root[i])) {
_root[i].gotoAndStop(2);
_root.score += 1;
}
}
}
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 0) == "bad") {
if (this.hitTest(_root[i])) {
_root.lives -= 1;
if (_root.lives == 0) {
_root.gotoAndStop(2);
}
}
}
}
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 4) == "save") {
if (this.hitTest(_root[i])) {
_root[i].gotoAndStop(2);
_root.score += 10;
}
}
}
}
View Replies !
View Related
How To Take Time From HitTest True To HitTest False?
hi
i have 2 MCs one is going through the other
and i want to take the time from the beginning
to the end.my code is this:
onClipEvent(load) {
this._visible = 0;
}
onClipEvent(enterFrame) {
first = new Date;
second = new Date;
indicator = 0;
if(!indicator && this.hitTest(_root.rocket)) {
indicator = 1;
sec = erst.getSeconds;
mil = erst.getMilliseconds;
begining = sec add ":" add mil;
}
if(indicator && !this.hitTest(_root.rocket)) {
indicator = 0;
seco = zweit.getSeconds;
mill = zweit.getMilliseconds;
end = seco add ":" add mill;
xposi = getProperty(_root.rocket, _x);
yposi = getProperty(_root.rocket, _y);
position = xposi add yposi;
}
}
further i want to show begining, end and position in 3 different textfields, but nothing works at all !!!
can it be, that it doesn`t work, because "this" is a symbol
in a symbol?!?
thx
bo
View Replies !
View Related
Hittest=false, Trying To Do The Opposite Of Hittest.
This question may have such an easy solution it might be worth for the newbies section...
I need an mc to do an action (go to a certain x point) whenever the mouse ISN'T over a particular box. So basically I would need to revert the typical
if (hitTest( _root._xmouse, _root._ymouse));
Anyone knows how to do this?
Thank you soooo much!
View Replies !
View Related
HitTest...creating The Opposite Of A HitTest
When I roll over a mc an enter frame triggers a function that is designed to evaluate when the mouse moves off the mc...how do you test for the opposite of a hitTest? I though in an "!", but didn't work.
PHP Code:
var buttonTarget:String = "targetMarkets_mc";
root[buttonTarget].addEventListener(MouseEvent.MOUSE_OVER, overHandler);
function overHandler (event:MouseEvent){
root[buttonTarget].gotoAndStop ("active");
root[buttonTarget].addEventListener(MouseEvent.MOUSE_MOVE, mouseEval);
};
function mouseEval (event:MouseEvent) {
if (!root[buttonTarget].hitTestPoint (mouseX, mouseY, true)) {
root[buttonTarget].gotoAndStop ("inactive");
root[targetMC].removeEventListener (MouseEvent.MOUSE_MOVE, mouseEval);
}
};
Also, how do you remove the event listener? Is there a need?
View Replies !
View Related
Needs EXPERT Help: 1. Save Game For Replay, 2. Reset Game
I'm rather new to Action Script, but doing not bad. I have searched the Board, found a link to a tutorial on ActionScript[Org], titled: "save a local copy of file". But that was yet not clear enough for me.
2 Questions at the moment (files attached):
1. Save Game for Replay: How can I save the set to a file in the Same Folder so it could reload for further play from that point on?
2. Reset Game: How can I Reset the Game for a NEW Attemp? I need to remove all Actors at once, to start a new game, without closing this SWF and reopenning it.
If you'd be so kind as to explain very clearly, and add Action Script, taking into consideration that I still get confused by trying to deal with Arrays and so. I promise to study your lesson carefully - this GameTest attached is the fruit of this week studies.
THANKS A LOT
Nit Kalish
View Replies !
View Related
Flash Game Help The Game Runs Too Slow In A Browser
lo there!
I'am so frustrated!
I have made a plattformgame in flash, and after I had published it I tested it (local) when it was embedded in a browser, and it hacks and laggs! But when I play it in the flash player it works just fine.
What should I do?
I removed all the heavy graphics, lowerd the fps to 30fps and removed all the code so now its just the bassis left (gravity, collision, key checking etc. and yes u should bounce on the walls giving a wall jump effect).
Anyone please! I am in big need of help!
Is it my code? Did I publish it wrong?
here are the links:
http://smh03.lbs.se/smh03niklas/prof...ofilbollen.swf
http://smh03.lbs.se/smh03niklas/prof...ofilbollen.fla
http://smh03.lbs.se/smh03niklas/prof...filbollen.html
//Qui
View Replies !
View Related
How To Disply Time In Game And How To Stop After The Game..
Hi all,
i need help on drag and drop game...
i have done the drag and drop function, for this game timer has to be shown, after user finishes the drag & match, it should give finish alert and time taken for this game (please tell me also how to stop time after he finish the game) is to be sent to some external file or some database...
can it be done?
i have attached the .fla file also..
View Replies !
View Related
[F8] Game Studio Needs Flash Game Programmer
Hi -
I've been working on cartoon Flash interfaces for awhile. Now my clients want games, so I'm looking for one or two Flash game actionscripters who can help out and maybe start a studio. Since it's a startup, I'm looking for someone who's good, but not yet making millions - hoping we can do that ourselves eventually. Someone dependable, easy-going and easy to get along with. Would be great to find someone relatively local, but not absolutely necessary.
We'll be creating custom Flash games for an existing client.
Hoping to check out people's games first.
J.
View Replies !
View Related
[F8] How Can I Make A Game With Levels And A Game That Restarts?
I know this sounds stupid, but I just can't figure it out. I need to make a platform game. I'm fine with making a points system and a scrolling background and it functions but I don't know how to get the player to touch an object, or reach a goal and then transport to another level...I don't want to make the user have to click something to go to a new level.
Also, when the character hits an enemy, I can make it die, but I don't know how to make a button or something appear saying 'Game Over - Try again', so they can pretty much restart the level.
Hopefully someone can help me.
Regards,
Andrea
View Replies !
View Related
Help With A Game.. Game Is Running Slow In Browser..
I am working on this game for work and for now all i have is placeholder art for the most part and nothing very heavy on the graphics end yet my game is running very slow.. i bumped the FPS to 60 since at 30 i was getting image tearing or a double vision effect.. the upped FPS fixed that but the game is still running very slow. To give you an idea of what's going on i have different intervals running so different things can happen at different times.. there are 2 constant onEnterframes for the 2 enemies flying around the screen.. there is 1 for the main loop, 1 for the character, 1 for whenever tickets generate which removes itself and deletes the enterframe when they disappear, 1 for the wrecks that occur on level 2 which also remove themselves and delete enterframes for themselves, and 1 for a holder that handles all the money flying in which removes themselves as they collide with the player or leave the screen. All enterframes that run during gameplay delete themselves at the end of each level and re-initialize at the beginning of the next.
I can't figure it out.. please take a look at the fla and html files attached. Could it be just the sheer size of the game screen.. should i make it about half the size?? I appreciate any help and thank you.
Also the game's scripted animations seem to be running a little choppy if you watch their movement closely like there is a little glitchy jump every second or so.. is this fixable?
View Replies !
View Related
AS Help Needed In Game(i Will Give Credit In Game If You Help)
ok so basicly this is my game so far
23.swf
my probelm is that i want to make my charcter a flame and the tips of his head will move depending on the direction you are going.
So here is basicly this what its like
Moving left-Flames bend to right
Moving left and down-Flames bend at an angle between the left and down
Moving Down-Shorter Flames
Moving Up-Stretched Flames
etc...
ill put borders on after i get the flames down
View Replies !
View Related
|