ActionScript 3.0 :: Remove A HitTestObject In A Game?
Dec 1, 2011
Basically every functions without hitTests are removed without errors, but all the ittestobjects that i have in the end game frame says that it cannot acess a nullhitTestObject. One of the hitTests i have is this one:
if (this.hitTestObject(_root.anulpowerups)) {
this.parent.removeChild(this);
removeEventListener(Event.ENTER_FRAME, checkCollision);
[code]....
View 3 Replies
Similar Posts:
Feb 2, 2011
Before i ask what im sure will be a very silly question, let me say that i am a total beginner at Action Script. I am trying my best to make a simple game for University, and i have tried, but cant figure it out.
Anyway, the game is basically Breakout, where you control a Paddle, and try to hit a ball towards blocks.I cant figure out how to remove the blocks when the ball hits them.[code]...
View 8 Replies
Aug 17, 2011
I'm new to ActionScript but I've been following Lynda tutorials and tried to tailor them to my game. I simply want to make my character at the top of the screen shoot at enemies below. The error I'm getting when I press the shoot button is "Parameter hitTestObject must be non-null." I've read some other forum posts on this error for ideas but still can't seem to make mine work.
{
import flash.display.MovieClip;
import flash.events.Event;
[code]......
View 3 Replies
Mar 22, 2011
I'm making target shooting game and the hitTestObject not working its located in the function collision detection below in my code:
import fl.motion.MotionEvent;
import flash.events.MouseEvent;
var xSwitch:Array = new Array ;
var count:Number = 120;
var seconds:Number = 0;
var minutes:Number = 0;
[Code] .....
View 1 Replies
Feb 17, 2011
Code is working but i am getting the following error and it is driving me insane:
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display:isplayObject/_hitTest()
at flash.display:isplayObject/hitTestObject()
at PlatformGame/checkCollisions()
at PlatformGame/gameLoop()
Here is my Frankenstein code...i just need it working. Error happens when I remove the numOfKeys-- where I examine the level. Had to remove some code because of length when posting here on FK.
View 1 Replies
Jan 14, 2010
flash and am trying to create a vending machine game but I seem to have come unstuck. The coin_slot that I have added doesn't seem to remove from the stage after frame3. I have included colour to the the event triggers to allow me to see what is happening at the moment the coin_slot image that I add does seem to remove from the stae but there still seems to be something hidden within the stage. This is still in really rough stage of development I just need to figure out the code at the moment.
View 3 Replies
May 4, 2011
So i have this flash game with couple of different scenes And im trying to remove all of the movieclips when the scene ends because i keep getting a loop of errors, for example this one TypeError: Error #1009: Cannot access a property or method of a null object reference. at BlobBobScenes_fla::MainTimeline/star() I have tried removing these
[Code]...
View 4 Replies
Aug 13, 2011
I'm building a word search game using the following AS3 code. My problem is I need to have spaces in my array of words, so that I can have things like states names, but I need the spaces removed before the words go into the puzzle.
The other concern is also that when a person selects a word from the puzzle will it still match the word in the list even though the word in the list still has a space.[code]...
View 1 Replies
Nov 24, 2011
I'm trying to create a flash shooter game as my first project. But I can't remove the bullets and enemies when they are hit or off-screen.I've searched for a solution on the problem multiple times and copied about 4 of them (plus I've tried my own ideas) but they are not working.The current method of checking for collisions is:[code]How can I remove the enemies and bullets? removeChild and splice?
View 1 Replies
Apr 7, 2010
i followed this tutorial: http:[url]....and all has work out great however, then i go onto anouther frame how do i remove all movieclips from the created game arrays?
View 3 Replies
Jan 19, 2012
I've only started using Actionscript 3 recently and am having difficulty removing a number of childs from my flash game (a variant of frogger). My aim is when the player's character (WWalk) touches the EndGameZone on the other side of the stage, the generated Lorries should disappear, so I can put an ending animation on scene two. I can get it to load Scene 2 but cannot get rid of the lorries - They just stay still and don't disappear.
Code:
stage.focus = stage;
//adding keyboard control over the character to control direction
stage.addEventListener (KeyboardEvent.KEY_DOWN, CWWalk);
function CWWalk (e:KeyboardEvent) {
switch (e.keyCode) {
[Code] .....
View 1 Replies
Jan 7, 2005
I tried to do a space game But there is a big big big problem I couldn't remove the movieclip (bomb)Here is the fla CAN YOU HELP ME?
can you remove the "fuse" for me
View 5 Replies
Jan 8, 2007
I am trying to remove all absolute references to "_root" from a game I am making. I have tried to avoid this kind of referencing where possible, but there seems to be some situations where I simply cannot make a reference by means of relative paths.
[Code]...
Which returns the mc that the tween was applied to. But using ".obj" only seems to work with Tween objects. Can anyone explain the idea behind using relative paths with objects that trace a data or class type when tracing "this".
View 1 Replies
Apr 8, 2010
In my program, the movieclips are randomly added on the stage, If I want to check whether two movieclips from different classes is colllided.As far as all the moveclips are of the different classes which are randomly added on the stage in my program,for the use of hitTestObject(), I find that I need to have two movieclips identified so that the command will be:
mc1.hitTestObject(mc2)
maybe I may ask, before I add a mc on the stage "addChild(mc)",I will call a function to do the hitTestObject command "mc.addEventListener(Event.ENTER_FRAME, hitTest)"so that I can call evt.target to be mc1, is that true or not?
View 14 Replies
Jan 5, 2012
Im've created a timer that starts every 1 second. This is the code what's happening every 1 second.
var Random_Value_X:Number = Math.ceil(Math.random() * 1500);
var Random_Value_Y:Number = Math.ceil(Math.random() * 2000);
var enemy:MovieClip = new AI(stage);
addChild(hero);
enemy.x = Random_Value_X;
enemy.y = Random_Value_Y;
Ok. Then I got the class called AI where I've made it so the AI follows my player. The thing is, I need to make a hitTest that testes if an AI hitting another AI? Is there a way I can give every new AI a ID? Like the first gets called "AI1" and second AI2" and then I can make a code that says like If(AT1.hitTestObject(AT2 || AT3))
View 1 Replies
Sep 12, 2009
I am trying to develop a basic game engine for a slime soccer style game where a player can move around and jump. I am still fairly new at AS3 but managed to put together this working bit of code that the game currently runs on:
Code:
stop();
//vardefs
var runSpeed:Number = 10;
var blueGoals:Number = 0;
var redGoals:Number = 0;
[Code]...
View 4 Replies
Jan 9, 2012
I have children being added to the stage, and they all have the same name:
[Code].....
and then inside them I have them looking for a hit test of any movieclip with the name art_crab, but I keep getting a null response...
[Code]....
how i can make sure that they collide and i dont get this response?
View 7 Replies
Nov 13, 2009
I have a project with four circles moving randomly on stage (ball_mc1..ball_mc4). There are four walls making a box (wall1..wall4).I've created arrays for both myCircles and walls.When myCircles hit walls, I would like to change the direction of myCircles depending on which wall they hit.
stop();// walls or limits and their arrayvar walls:Array = new Array (wall1, wall2, wall3, wall4);for (var j:Number=0; j<walls.length; j++);
// circles in arrayvar myCircles:Array = new Array (ball_mc1, ball_mc2, ball_mc3,
[code].....
View 11 Replies
Feb 7, 2011
I have section of code which works for bouncing some fish movie clips off of the 'ceiling':[code].....
However, I would like to find a more succinct way to program this using a 'for loop'. I tried the following, which did not work and gave me an error (posted at the bottom). [code].....
TypeError: Error #1010: A term is undefined and has no properties.at Function/<anonymous>()
View 3 Replies
May 12, 2011
Im trying to get Flash to rember if the logo_mc has been hitTested with the holder, and if it has when the movie is played again it appears in the box and not the original spot
var mySO:SharedObject = SharedObject.getLocal("ObjectPlace");
var logo_mc:Sticker = new Sticker ;
addChild(logo_mc);
[code]....
View 1 Replies
Nov 30, 2011
How do I get the x,y position of hitTestObject? Since I want to obtain the x,y position where the hit test occurs and add a movieclip on that specific point....
View 2 Replies
Jan 16, 2011
I have a MC called 'playerP" and inside of it with 7 different MC. I can't seems to hit test on the children MC, it always show [object position_2]
private function cMove(e:MouseEvent):void
{
trace(MovieClip(playerP.RR), playerP.PT)
[Code]....
View 1 Replies
Feb 8, 2012
I am building a pacman style game, and I am looking to shorten my code.The stage contains 92 instances with instance names of food1, food2, etc.When the player(pacman) hits one of the instances Im wanting to call a funcion.I started writing it out like this... it works but I don't want to duplicate this 92 times!
if( player.hitTestObject(food1) ) {
updateScore();
}
if( player.hitTestObject(food2) ) {
updateScore();
}
Now I'm trying something along these lines, but with no success yet.
function collectFood() {
var i:Number;
var pGroup:String
[code]....
View 1 Replies
Mar 14, 2012
I would like to make a button that allows you to go to the next frame. I would like to do this with hitTestObject. When the charecter walks over the button, you should go to the next frame.
View 1 Replies
Sep 30, 2010
I'm hoping someone can help me. I'm trying to add sound to the hitTestObject script below so that a short sound plays everytime "bolt" hits the ralphie_mc.
[Code]...
View 0 Replies
Dec 15, 2011
I'm working on a scene where the user can drag sugar, honey and syrup flavour to a cup of coffee and each time they collide, the coffee's happiness is increased by 1. I added a TweenLite so that sending any of the objects to their original positions is much more fluid. The problem is that the hitTestObject is now firing more than once (which makes sense and now happiness is increasing at more than one increment at a time) but how can I make it so happiness is increased just once?
Code:
public function hitsDecaf(e:Event):void{
if (myCounter.myHoney.hitTestObject(myCounter.decafSweetened)){
ifStartTimer = true;
stopDrag();
myCounter.steamHappy.gotoAndPlay(2);
[Code] .....
View 4 Replies
Sep 25, 2009
I'm trying to make a simple maze game. I have movement working, and now I'm trying to implement collision. Here's what I have:
An 8x8 grid, with walls of length 1 to break the grid up into a maze. the walls are instances of a movieclip I've named "mc_wall" a guitar-pick-shaped chip I'll control the movement of a cross-hair called "arms" that will check if there are walls immediately surrounding my chip by way of collision. "arms" is a movieclip made up of four individual movieclips: "uparm", "leftarm", "rightarm", and "downarm"
I have currently named each instance of "mc_wall" to be "wall" this is the code I have now (using only right as an example):
function moveRobot(event:KeyboardEvent):void
{
doslide = true;
if (event.keyCode == Keyboard.RIGHT)
[Code]....
this will work, causing the chip to remain in place if the rightarm detects "wall", and move if the rightarm does not detect "wall". My problem is that, although I have named every instance of "mc_wall" to be "wall", the only "wall" flash will recognize is the last one.
Is there a way to adjust this code to look at all 70-or-so instances of "mc_wall" instead of only the last one?
View 1 Replies
May 16, 2011
Ok I am building a DnD, I have a hitTest setup, and I know when it hits it. But I can't get out of the for statement if I drop it on the second object. It says it hit it, and then anims back to org. place.
Code:
public function onStopDrag(evt:MouseEvent):void {
stopDrag();
[code]....
View 5 Replies
May 26, 2011
Press the picture to get it larger. That's what i really need for my project. I can't get it to work.please explain it for me to, im learning flash so I can need that to understand sometimes
View 1 Replies
Sep 4, 2011
I dont think that will work. I need to have it as individual blocks.I did a quick demo file to show what I need. You will se in the file that the map is randomized and I need it to be like that to! READ THIS: I want the green cube to fall down (gravity) and than "land" on the gray cubes. This is a small demo, of my full version flash file, so i need it to be blocks.
View 4 Replies