ActionScript 2.0 :: Arcade Game HitTest - Only First Frame Of MovieClip

Nov 10, 2004

I'm building a a space shooter "Defender" type game, and I'm having a problem with the hit test. My laser hits the enemy (which a duplicate). Enemy movie clip goes to it's frame to which a short explosion animation. The hit test works fine, but since there is more than frame in the "enemy" movie clip, the hit test cycles through every frame of the "enemy" clip until it passes through it's boundaries. Is there a way to only have it hit test with only the first frame of a movie clip?

This is the script on my laser movie clip that performs the hit test:
if(this.hitTest(_root["enemy"+i])){
_root.score+=100;
_root["enemy"+i].gotoAndPlay(2);
this.removeMovieClip();

View 2 Replies


Similar Posts:


F8 :: Glitchy Arcade Shooter Game

Aug 15, 2009

I've only played around with a dressup and dating sim - and coding using actionscript (and coding in general, only done a little bit of VB and Python before). I've been following a nice arcade side-scroller tutorial on this site which has three parts, if you want to view and go over them to help. It was designed for Flash 5 and I'm using Flash 8 Pro.[code]Anyway, as I was going through and coding/drawing the whole thing I came across a lot of problems and glitches (and a lot of times when the game coding would crash and I'd have to abort it and remake the entire coding again). I sort of stumbled around blindly, deleting and editing code to get things to work, and I'm up to the point where I'm almost finished with the thing. It's still glitchy though.I was wondering if any Flash coders could help me out?I'm going to be creating a Flash game for my programming class and I would prefer if it wasn't screwy (if I need to remake it with less cutesy graphics). xD;; If you could download the .Fla file and fix the coding problems I have.

Playable SWF game on my deviantart account.FLA downloadable file (@ Mediafire; no viruses, trojans, blahblah attached)The enemies tend to randomly explode before the missile has even hit them.The original enemy movie clip doesn't even want to explode.The score counter won't tick for each kill.The boundary box (?) of the player/enemy seems to be too big. You die before you should - in certain positions the enemy gets close and I guess the boundary boxes hit, which initiates the hitTest. It seems premature though, I'm wondering if I can reduce the boundary box, or have it so the enemy and player collide on the actual graphic, and not the movie clip box? I have no idea if this makes sense, I hope it does.There seems to be a bunch of other small glitches too.

View 6 Replies

ActionScript 2.0 :: Create An "hitTest" Script Inside A Movieclip That Is Actually Part Of That HitTest Code?

Jan 15, 2009

i just would like to know how to create an "hitTest" script inside a movieclip that is actually part of that hitTest code?I mean... I have mc A, and mc B. and the current hitTest code im using (that is on the timeline) makes mc A, destroy mc B when collide with it... but there are many mc B on the stage (with the same instance name) so, when mc A collide with one mc B, it destroys ALL mc's B... but i want it to destroy only the mc B that he collides, not all the others... maybe an hitTest script inside a movieclip B would work (somethig like "if MC A hitTest ME = i die" (not all the others)).

View 1 Replies

ActionScript 1/2 :: Flash Game - Putting Each Armor And Update On A Different Frame Inside The Player Movieclip?

Jan 29, 2011

I am trying to create my first semi-serious flash game. The problem I am having is I want to be able to click a button in the players inventory to equip a different armor to the player, and have that armor work in the game on the same movieclip(Player) without having to re-make all the attacks and moves etc. for each change on another movieclip. My ideas are extremely novice like putting each armor and update on a different frame inside the Player movieclip and then doing a gotoAndStop to the frame. Though that may work I don't know how to goto a frame inside a movieclip. I would like to control this using as much code as possible.I would paste my code but I don't have any code for this part of the game so far. I have tried some simple coding but so far I cannot get the pieces together.

View 1 Replies

Actionscript 3 :: Add Seconds To (game) Timer After Hittest?

Dec 24, 2011

I have a timer and a dynamic textfield wich displays the time. Everytime my movieclip hits an enemy I want the timer to add 4 sec. to the current count. I would like to know why this isn't working:

timer.currentCount + 4;

(does nothing)

timer.currentCount += 4;

(error: property is read-only)

View 2 Replies

ActionScript 3.0 :: 3D Projectile Game - HitTest Point

Mar 4, 2011

I have a 3d projectile game I'm working on. I want to check if the projectile moving down the z axis hits wall on two sides. The walls are set up like this:
leftWall = new wall();
leftWall.x = 10;
leftWall.y = 360;
leftWall.z = 230;
leftWall.rotationY = -95;
How to do collision detection in this 3d space?

View 2 Replies

ActionScript 3.0 :: AS2 To AS3 Conversion / Simple Score & HitTest For Bug Splatter Game

Sep 26, 2011

Non-programmer here, struggling with having to now (finally) work in AS3.I've looked around, but can't find something similar (or as simple) as my old AS2 scoring - hitTest method was.Problem 1: my converted AS3 game does not hitTest or score.[code]I have a Dynamic text box on the stage named "scorecounter" which is now displaying "0" when the game plays. This is correct.When the gun (mouse) is clicked, we then tell the "hittest1" MC to play, which will detect hits. All Correct.[code]The hittest1 MC plays, and checks if the "cursor" MC was touching the "bug1", and tells it to animate (splat) All bug detections are listed in the hitTest frame - "bug1" through "bug30", ie. the code below x 30. This Fails - maybe because the hitTest MC lists all 30, and not all bugs are visibile at once, some are hidden until required later in the game?[code]Then on the last frame of the "bug1" MC (frame 10), it tells the score to add one. Also Fails - maybe because of errors above, nothing is being processed now.[code]

View 5 Replies

ActionScript 1/2 :: HitTest - Reset Game When Falling Box Touch Certain Object

Jun 30, 2009

I am new to flash and im trying to make a game. Im stuck on hitTest. I have many black boxes falling down and I want the game to reset when the black boxes touch my red circle. I used this code for my boxes:

[AS]
this.createEmptyMovieClip("canvas_mc",10);
myInterval = setInterval(addbox1,500);
function addbox1() {
[Code] .....
My red circle is controlled by the mouse. The code for that is:
[AS]onClipEvent (load) {
startDrag(this, true); }[/AS]

View 6 Replies

Professional :: Drag And Drop HitTest, Dressing A Model Game?

Mar 19, 2010

I need to create a game where you drag and drop clothing onto a body that snaps into place then when the body is fully clothed you click a button to see if the clothing you selected is correct. There will be 4 different areas of clothing with 3 options for each area, one for each area is correct. how to achieve this? In either actionScript 2 or 3.

View 3 Replies

Flash :: Survivor Game (ennemies Going Through Walls, HitTest And Flashlight)?

Jun 5, 2011

I posted a bit earlier about some problems I had with a game I'm trying to do.[URL].. My first and main problem is that the ennemies are going through the walls. I can do a hiTest like with the player so that the collision is detected, but I don't know how to make the ennemy change direction. I thought it would be quite simpler if the ennemies could not move simultaneously on the x and y axis, but don't know how to do it. (then they would only need to make a 90 degrees turn)

Second problem is the hitTest for detecting collisions with the ennemies. It seems like I'm not able to do it. There is the part which I thought would be good at the end of the script in commentary. Third problem, which is the least important in my eyes is that we see the ennemies even if the "flashlight" is not aimed towards them.

[Code]...

View 1 Replies

Professional :: Make A Hyperlink With Arcade Button?

Sep 23, 2010

I do not know really anything about ActionScript. I have completed a tut on it but that is all. I am trying to make a hyperlink from a classic arcade button but the code I found is apparently from AS2.

View 1 Replies

ActionScript 2.0 :: [FMX] Game - Hittest With Movie Clips In The Centre Of The Stage And Distance

Apr 26, 2005

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.

View 3 Replies

ActionScript 2.0 :: HitTest And Positioning - Create An Invisible Movieclip That Has The Exact Size And Shape Of The Animated Movieclip

Aug 23, 2005

This is the third thread I've written for my current project (1st was answered perfectly, 2nd failed [but I still figured it out anyways]) but I'm not sure if there is a solution to this problem. I can't really explain my problem, so once again I've included a helpful animation to show you what I mean. Bear in mind that the pale-blue box represents the movie clip's borders, and those borders are usually changed to include the animation (instead of the borders moving with the animation, the borders get bigger).

For the animation problem, I've already got a solution: create an invisible movie clip that has the exact size and shape of the animated movie clip and make it follow the movie clip as it animates, and make the hitTest check the invisible movie clip instead of the animated one. As for the rotation problem, well, I don't know how to fix it. Is there a way to change that?

View 1 Replies

ActionScript 2.0 :: Using Hittest To Move To New Frame?

Oct 6, 2010

I have a maze with a mc controlled by using the keyboard arrows. I have also created another mc at the end of the maze so that when the original mc controlled by the user reaches the end it moves to the next frame.

View 4 Replies

ActionScript 2.0 :: HitTest From Frame One Of Main Movie (MX04)

Nov 5, 2006

My fla is too big to upoad here [URL]. What I was trying to do is to get the animation on 'bt', or 'b1'( they are stacked on top of each other) to gotoAndPlay "_over" when it hits the lower red dot(instance 'oneHT') and then gotoAndPlay "_out" when it hits the second higher red dot(instance 'twoHT'), and then do the same for each windmill blade as it passes the red dots during it's rotation. When I attach script to the movieclip it works, but I'd like to just keep all the actionscript on the main timeline so I dont' forget where I put things.

View 3 Replies

ActionScript 1/2 :: HitTest The Same Movieclip?

Sep 4, 2011

_root["zombie"+i].onEnterFrame = function() {
if(this.hitTest(this)){
trace("hit!");
}
}
 
This does not work, it traces hit! even if none of the movieclips are touching. dont know how else I can do this.

View 9 Replies

ActionScript 2.0 :: Current Movieclip With Hittest

May 15, 2009

I'm setting up a project that has a list of 45 words. The user should be able to drag the words into an area on the stage, as many as they want, but unable to proceed until they have only 5 words in the selected area. I started off by making each word a movieclip and making them draggable, but wondered if there was a way to simplify the code rather than putting it on all 45 movieclips, if there was a way to have it know which one i'm currently dragging.

Then I was unsure how to keep track of how many were in the area. If i have a count that gets increased for each hittest, it goes up and up, but you can continually redrag the same word on which is wrong. But the user needs to be able to drag words out, so I can't disable them when they hit.

[Code].....

View 10 Replies

ActionScript 3.0 :: Allow HitTest Of MovieClip To Hit Only One Object?

Jul 19, 2010

Is there a way that only allow hittest of a mc to hit one objects, if it hit multiple object it ignore it?

View 1 Replies

ActionScript 3.0 :: Hittest On Dynamicly Created Movieclip

Jun 16, 2009

this i have this code at the moment and i want to add a hittest to the "bullet".i have created.[code]but this doesn't seem to work.

View 3 Replies

ActionScript 1/2 :: Restart Ball MovieClip After HitTest

Feb 13, 2011

I have recently started to learn about flash and as2 and I am working on a small shooting style game. I have managed to create a hero that moves around the screen and enemies which I shoot at. The issue I am currently having is that on my ball movieclip (bullett) the first frame holds a ball and the 2nd frame is a small animation of the ball breaking apart. So basically when the ball is thrown and the hittest comes back true the 2nd frame plays showing ball breaking apart. Now when I fire a 2nd time it constantly plays the 2nd frame of the broken ball. How can I restart the ball movieclip in its 1st frame to carry on shooting normally.

Below is the as2 I have on my ball movie clip.
onClipEvent (load) {
var statee;
statee = "ready";
maxJump = -30;
grav = 0;
gravity = 1.5;
[Code] .....

View 4 Replies

ActionScript 1/2 :: Create HitTest And GotoAndPlay MovieClip

Jul 21, 2011

I have three symbols. First is a Shield MovieClip, where in the first frame I have placed a stop(); Action and the second frame is where the animation starts..Second is a Ship and third is a PowerUp. Inside the Ship symbol, I placed the Shield MovieClip. I wanted to create a hitTest when the Ship hits the PowerUp, the Shield MovieClip inside of the Ship will start playing.

This is my code that doesn't work:
if(this.hitTest(_root.ship)) {
root.Ship.Shield.gotoAndPlay(2);
}

View 1 Replies

ActionScript 3.0 :: Using HitTest From Within Class With MovieClip On Stage?

Aug 26, 2011

I'm getting really tired of AS3 now because I cant get it to do basic things like hit tests which were so easy in AS2. Basically, I generate a number of fish of varying scale, speeds and directions using this on the first frame of the timeline and the constructor function in the fish.as file:

ActionScript Code:
function DisplayFish() {
for (var i:int = 0; i < 20; i++) {
var newFish:fish = new fish();
this.addChild(newFish);
[Code] .....

What I want to do is rather than setting a max / min x/y use a hit test with a side wall MC on the stage, and a hit test between this instance of fish and all other fishes so they bounce off each other. I've tried so many ways of hit testing from within the class with MCs on stage but just cant get it to work.
ActionScript Code:
if(this.hitTestObject(root.LeftWall)){
directionX = 1;
}

View 6 Replies

ActionScript 3.0 :: Accessing An Instance Of Parent Movieclip For HitTest?

Dec 13, 2009

I have a stage with instances of bauble_mcs on it that are attached by the document class of the main timeline (can someone tell me what the right term is here? I don't know what I call the main time line in AS3).I then have instances of snow_mc attached by the same class. Inside the snow_mc I want to test to see if it is hitting any bauble_mcs but I don't know how!

inside snow_mc I am trying:

PHP Code:

if(this.hitTestObject(this.parent.bauble_mc)){
}

to which flash says:

1119: Access of possibly undefined property bauble_mc through a reference with static type flash.displayisplayObjectContainer.

View 1 Replies

ActionScript 2.0 :: Movieclip As Button HitTest Working Intermittent?

Jul 9, 2004

I was playing around last night trying to learn simple AS to make a movie clip act like a button. I wanted the button movie clip to reduce the alpha value of the other movie clip when you rollover the button and when you roll off the button the alpha of the movie clip goes back up. It works, but if you keep rolling over and out of the button movieclip sometimes the alpha gets stuck at a certain value for a bit, then does what its supposed to. I'm using onEnterFrame () to do the hitTest constantly.

Here's the SWF and FLA files for you to look through:

hitTest SWF
hitTest FLA

Here's the AS code I used in the frame to do this:

Code:
onEnterFrame = function() {
if ( background._alpha > 100 ) {
background._alpha = 100;

[code]....

View 12 Replies

ActionScript 2.0 :: HitTest Only The Content Of Movieclip And Not From 0,0 To _width, _height?

Nov 7, 2006

This is probably just a brainfart but when I publish the code below, my hitTest is triggered by the entire movieclip from 0,0 to _width, _height and not by it�s content. The �fwa� movieclip contains some txt that I broke apart, and I only want the hitTest to run when the �mc� hits the txt within the �fwa� movieclip!

[AS]
var i:Number = 0;
var count:Number = 0;
var colorArr = ["0x99cc33", "0xff0066", "0xffcc00", "0x33ccff"];

[code]....

View 2 Replies

ActionScript 3.0 :: HitTest For Mouse Position Over A Bitmap Inside A MovieClip?

Dec 1, 2009

This seems like it should be simple, but... I've been trying to figure out how to do the following, and I can't seem to make it work. It all works except for the hit test part. I have a working drag and drop application. I need something different to happen when the user drops an object while the mouse x,y is, or is not over a certain (very irregularly shaped) bitmap inside a movieClip. how to do this? I have found some complicated ways to hit test between 2 bitmaps, but not 1 bitmap and mouse x,y.

View 3 Replies

ActionScript 3.0 :: Apply Hittest Object / Point Condition To Only One MovieClip?

Jul 9, 2011

i'm breaking my head over something, and will be very grateful to any creative ideas:

I created kind of drag and drop game: i have cards that should be placed on squares.

in case the card touches any square, the square changes it's color. the problem occurs when the card touches 2 squares at their middle: they both change their color.

in fact, I need that only one of the square will change it's color, and it should be the square that the card touches it with "the most of him". i thought of using the hitpoint but i know it won't work, because in case the card touches both square in the middle it won't work..

View 2 Replies

ActionScript 3 :: MovieClip HitTest - Fire Event When Object Clicked By Mouse

Oct 25, 2011

I have a MovieClip. It represents animation of jumping monster. For clearness, let's pretend there are only 2 frames: the first one occupies top left rectangle (x = 0, y = 0, w = 70, h = 70) and the second one occupies (x = 100, y = 0, w = 70, h = 70). So monster jumps from left to the right. And position of MovieClip itself is constantly = (0, 0).
I'd like to fire some event when monster is clicked by mouse.

For some reason, I have stage mouse listener, not monster mouse listener. I wrote this code:
stage.addEventListener(MouseEvent.CLICK, onClick);
private final function onClick(e:MouseEvent):void {
const clickPos:Point = new Point(e.stageX, e.stageY);
// having monster:MovieClip, how do I check hitting it?
[Code] .....

View 1 Replies

ActionScript 2.0 :: When Trying To HitTest Bombs With Boundries / Enemies Inside Of 'world' Movieclip

Jun 5, 2006

URL...The game has a helicopter centered on the screen (the heli movieclip is in Scene 1, frame 1, Layer 2). Then I have a "World" movie clip on Layer 1. Inside the world movie clip are the enemies, weapons, and boundries of the map.The world movie clip is moved when the controls are used to make it look like the helicopter is moving (although it is actually stationary). When the space bar is pressed, the "bomb" movieclip inside of the "world" movie clip is duplicated, and the duplicate is placed at the correct coordinates in the "world" movieclip so that it seems like it is coming out of the helicopter. This is all working as intended.The problem comes when trying to hitTest the bombs with the boundries/enemies inside of the "world" movieclip. The "boundry" movieclip is also inside the "world" movieclip, and is part of the Boundry class. The hitTest is inside my "bomb" class. Heres the code:[code]But the hitTest just doens't work. I've tried every combination of legal hitTest statements between the two movieclips, and it wont work. As you can tell from the SWF...the bombs explode seemingly randomly. SO somewhere...somehow...the bomb is colliding with the boundry.

View 1 Replies

ActionScript 3.0 :: Smooth Frame Rate In A Game

Jul 6, 2009

I was wondering what is the best way to achieve a smooth frame rate in a flash game. I'm making a simple space exploration game where you fly around exploring systems and shoot enemies. I have a background movie clip which I move around to simulate scrolling. Enemies, planets and such move along with the background. My problem is that the frame rate I'm getting is very jittery. Most of the time everything moves smoothly but from time to time the game slows down or makes small "jumps". I'm using timer events with updateAfterEvent() for the scrolling and frame events for moving enemies relative to the background. The document fps is set to 60.

[Code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved