ActionScript 2.0 :: Shooting Game - A Gun To Follow The Player, But The Coordinates Are Messing Up And Going To His Feet?
Oct 25, 2010
I'm making a flash game in AS2, and i am having troubles with my gun, i have fiddled with it for a while now and i have narrowed down the problem, but i can't fix it. My problem is that i want a gun to follow the player, but the coordinates are messing up and going to his feet.
Code:
onClipEvent (enterFrame) {
_y += (_root.player._y-_y)/1; //This code makes it goto his feet, but the gun no longer follows player when he jumps.
_x += (_root.player._x-_x)/1;[code].............
View 1 Replies
Similar Posts:
Feb 6, 2009
Shooting game in FlashView Game - Click hereKindly check game codeProblem:1) The rabbit should be random shown in ground areaif someone can give explaination onmonster.x = Math.random() * stage.stageWidth;and why the rabbit is showing bigger size?2) Other animals should also be able to target
//----->
stop();
var monstersAlive:uint;
[code].....
View 1 Replies
May 7, 2010
I am at uni and have a project to create an interactive game for the story Johnny Mnemonic. I would like to create a game whereby the player has a whip type weapon, there is an opponent jumping up and down and with the whip you attack them and cut off limbs -
I'm thinking it would be like a simple shooting ducks style game in terms of coding, the player has visible just a hand with the whip in it, you move the whip to your desired location click chosen button to hit, the whip then animates a flick, if it hits correct spot on bouncing opponent then an animation of the limb flying off happens, so the bouncing opponent is like the duck and the whip like the gun - if that is right at all?
View 1 Replies
Nov 23, 2005
I've been making this space shooting game but I'm having problems getting boundaries to work. I've read tutorials and done lots of searching here and couldn't get anything to work... On the main time line, there's 2 layers. One with the ship, and one with the background (both are movie clips). Inside the background movie clip, I'd like to add boundaries, almost as complex as a maze but not so restricting.. as in, a path to fly through that'd probably be as wide as the screen itself. Here's what I'm trying to work with. Use the arrow keys to move, space to shoot, and press control to toggle between fixed camera and fixed ship modes.
View 1 Replies
Feb 18, 2009
So the problem is basicly this: It all works just fine, but when the bullet hits the target it gets destroyed (this is ok) but also any bullet that was shoot before it (meaning also: with a lower y) gets destroyed aswell wich is anoying. Here's the code (left the comments so you can find your way around easier)
Code:
stop();//add a stop function too!
enemyspeed =1
life=3
var gameOver:Boolean = false;
[Code]..
View 2 Replies
Jul 15, 2010
I'm making a Space Invaders-type game. Y'know? Arrow keys to fly Space to shoot? Well, shooting isn't working so well. I have two .as files: Ship.as which controls the ship's ActionScript, and Missile.as which is supposed to control the missile. When I hit load it up I get the error: The class or interface 'Missile' could not be loaded.
View 2 Replies
Feb 13, 2011
I am creating a 2d platform shooting game. Currently I have my main character walking around left and right and the stage background also moves left and right.
The problem I am having is that if I go to far left the charater just walks 'off stage' and into nothingness but the stage still follows. How can I make it so if the character hits a certain point he just 'stops' and cant go left no more but can go right no problem. I have tried using hitTest with another movieclip but couldnt get it working.[code]...
View 1 Replies
Apr 4, 2002
Ok I am creating a 2d game similar to the original mega mans and mario for nintendo. The character moves back and forth using the left and right arrow keys on the screen and has a walk animation and all. The next step is to get him to shoot his laser gun. I want this to be done using the space bar key. What I have right now is identical to Kirupa's movement using X and Y values tutorial but it only moves one direction of course. How can I make it so that it will continue to move automatically after pressing space instead of having to hit the space bar each time I want it to move 10 units over etc.?
View 12 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
Jun 2, 2008
I'm making a shooting game, would like the gun to flip _xscale when you move the gun past half the width of the stage. Here's the script I made which doesn't work and is probably not written correctly:
if(_xmouse >= Stage.width/2){
_root.gun_mc._xscale * -1;
}
View 4 Replies
Dec 2, 2009
I have benn programming in AS2 for a while, but I'm moving to AS3, and I'm having some trouble with syntax and mostly with management of parameters and variables (actually I tried to work with functions in packages without good results T.T). The game has four different types of shooters, and all of them use the same bullet (shoot function). I have succeeded on disappearing the target (a coin in this case) when it is hit by the bullet, but the problem is that I can't quite find the way to dissapear the bullet properly. I keep receiving this message:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at eco_adm9_fla::MainTimeline/moveBullet()
[code].....
View 3 Replies
Aug 30, 2011
I'm doing the shooting game. In that character should move left and right by using the arrow keys. The background is movieClip with image. The character is walking very slow sometimes. And the zombies will come automatically. Why the movement is very slow sometimes?
View 4 Replies
Feb 6, 2011
Basically, I have a border(line) at the top of the stage so that whenever my ship's missile comes in contact with this line, it is removed and a rebound missile clip is attached.Here is the missile code:
Actionscript Code:[code].....The problem is that the rebound missile always spawns at left of the stage, not wherever the ship missile was removed.I'm not sure if I should attach the fla, action script files, swf etc. to the thread. Also, my flash version is CS5.
View 3 Replies
Jun 30, 2010
how to make it work.I have 3 layers.
1. top layer is an image of a cell phone with a blank screen (where I'd like the mask to be utilized)
2. the mask... which is paired with the cell phone image above.
3. the main/maskable image, which is only revealed by the cell phone's screen.
4. the very bottom image, visible all the time.
I need the base layer image (#3) to be static, and I need the top two layers to be able to follow the same mouse x/y coordinates. So far, I've only known how to have the mask and the masked image be one together, rather than be able to move the mask independently of the image I want to mask.
View 4 Replies
Apr 21, 2005
I have a menu for a website in flash where, an mc moves up and down and shoots...so that when the projectile MC hits a button, it clicks it.
1.) How do I make it so that the MC follows the mouse (like a custom cursor)..but is restricted to only going vertically
2.) how would you make it so that the mc can shoot anywhere....but when the fired MC hits a button, it acts as if it was clicked? My AS knowledge...is..very basic...so if you have any free time could you explain the codes?...so that I can learn from this...rather then just stealing your codes... but..if you want to just let me copy and paste...thats cool too
View 12 Replies
Jul 18, 2010
So I've created a script where a mc is clicked on and the player can draw a path using the mouse. I'm trying to figure out how I can get the mc to follow the path drawn out by the player's mouse and when the player clicks again, it erases all of the path.my code is below
Code:
import flash.display.Sprite;
import flash.events.MouseEvent;[code].....
View 14 Replies
Nov 21, 2009
I am trying to make the stage follow the player in AS3 (basically, so the 'view' follows the player and he remains in the center of the screen throughout).Here is what I tried:
Code:
this.x = player.x-stage.width/2;
this.y = player.y+stage.height/2;
View 4 Replies
May 27, 2010
I've been working on a game for my AS3 class that involves enemies randomly spawning from all direction and following the player in an attempt to collide with him. I can get the enemies to spawn from one direction as well as move in a single direction but I can't get the spawning from all sides or the following the player around to work.
I've been at this for a couple of weeks now and followed several suggestions and tutorials (including one from here) with no success and this thing is due by tonight . Here's the code from my enemy class. All of the code of the game is done through AS files with no coding done within movie clips or on the timeline.
package
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
[code]....
View 14 Replies
Sep 15, 2011
how to make the camera follow my hero (mc), I think the problems involve me using the mouse to move my player instead of the keyboard. This is my code:
var distx:Number;
var disty:Number;
var gravity = 0.6;
[code]....
The result is my Hero following my mouse and when I click it jumps. But the camera is not following it.
View 2 Replies
Feb 12, 2012
I am working on a first person shooter game, however i dont know how to make all the enemies that get created, to all move towards the character every few seconds then moving randomly for a few seconds, with the frequency increasing as the enemies move closer to the player. Getting that part is easy enough, the problem is i dont know how to make each enemy be able to do anything really independantly. Since my game works in a an external AS file, i cant access any of the class variables from within the movieclip of the enemies. Is there a way i can do this?
i already have code which rotates and moves the enemy towards a given point, as well as random movement, what i dont know how to is access the variables of the main class from the movieclips of the enemies, and vice versa ive found a way to do this, however it means i have to out the movement code within the enemies, as well as collision code, and that just laggs the hell out of the game when there is 5 or more enemies.
View 0 Replies
Feb 11, 2008
I'm trying to make a simple metric to feet conversion and no result shows up in the dynamic text field.
I have an input text field on the stage with the instance name x, then the convertButton, and then a dynamic text field with the instance name of result. If you need the fla I can uplaod it, but I think this is a simple problem that is eluding me...
here is my code:
Code:
x = '' ;
result = '';
//convert meters to feet
[Code].....
View 8 Replies
Jul 8, 2009
I can't remove the right-bar on Internet Explorer: [URL]. In Firefox and Safari everything is perfect... I use overflow-y property to do it. Is maybe not supported bye IE ?
overflow-y:hidden;
View 1 Replies
Feb 14, 2011
I'm an actionscript beginner and trying to write a class to make the 'enemies' follow the 'player' (shown below). I'm trying to write it such that it takes two MovieClips as arguments, and moves the first one toward the second one. When I import the Class try to use it in Main.as by typing " var followPlayer:FollowPlayer = new FollowPlayer(fishMov0, player);", I get the following error:
"ArgumentError: Error #1063: Argument count mismatch on jab.enemy::FollowPlayer/followPlayer(). Expected 2, got 1."
[Code]...
View 3 Replies
Oct 26, 2009
I found this tutorial [URL] and is wondering if I could limit the area where the clip can follow? I'm planning to have my cartoon's EYEBALLS follow the mouse move.
View 1 Replies
Dec 19, 2011
I was trying to convert global coordinates to local coordinates of a UIComplenent in my flex project using below code using below code
var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point
uic is UIComponent in which I have subclass of Sprite for drawing something I have set the sprite's mouseEnabled and mouseChildren to false to not interrupt the mouse event. above code is within uic's mousemove event where I was tracing the gp and lp gp was giving correct value and suprisingly lp was giving negetive values. when I move the move to the top left corner of uic i expect lp to be 0,0 but it is giving the -width of of uic. I broke my head for hours and ended up finding an alternate by using offsets. Infact my original code was much simpler like this which was same issue
var lp:Point = new Point(e.localX,e.localY);
I am not sure what exactly is causing this problem. the workaround had lot of issues and it creating a mess in my rest of the algorithms.Just now I found even more interesting thing (which is actually weird). for some reason I went and create a new lp2
var lp2:Point = new Point(e.localX,e.localY);
now surprisingly it was giving correct values as expected and I went back and changed the code as
var gp:Point = new Point(e.stageX,e.stageY); //global point
var lp:Point = uic.globalToLocal(gp); //local point
var lp2:Point = new Point(e.localX,e.localY);
var lp2:Point = uic.globalToLocal(gp);
now it is expected to have all the lp, lp2 and lp3 variables to be same but weiredly lp two is giving wrong value and lp2 and lp3 were giving correct. I am suspecting using the variable lp has something to do. I am not sure about that but above proves it so right now I am using lp2.
View 1 Replies
May 21, 2007
I was reading the 'Isometric Transformations' tutorial by Danko Kozar and I have a few questions. I understand what all the code does, but not how it does it. First of all, how does the following code work:
transforms x,y,z coordinates into Flash x coordinate
xFla = function (x, y, z) {
// cartesian coordinates[code].....
I understand that it converts 3d coordinates to 2d coordinates, but I don't understand how. What numbers whould be punched into x, y, and z to acquire certain desired effects?Also, what's the difference between moveTo and lineTo:
red line
style(1, "0xFF0000", 100);
plot(0, 0, 0);
draw(200, 0, 0);
View 4 Replies
Aug 27, 2011
if it is possible to make a game where two individual computers play the same game against each other. If so, is there any information out there explaining the steps? I have read a lot of books on making flash games. Also, does anyone know if [URL] is worth paying for a subscription?
View 1 Replies
May 3, 2010
Im making a little app in flash using papervision I want to make a regular movieClip show up in the same place as a papervision object. The coordinates seem like perspective is affecting the number displayed.
View 2 Replies
Oct 14, 2011
I'm new in these forums, so I don't know that this question is on the right place. If it's not, then please forgive me.
I have got a little question. What should I download if I want to write a 3D game for the Flash Player 11?I'm not new to Flash, I just don't know, what should I do if I want to program a little 3D game, that uses the native 3D acceleration.
View 3 Replies
Jul 3, 2006
Im making a game and trying to find the best keyboard keys. I mean, if u are holding down shift+d+f the final key f doesn't work bec. of keyboard buffer. etc. If someone know what kind of keys are the best match for flash 2 player game post them here please. So when like 6 keys are pressed at one time, the last keys pressed, will still work. And player won't get stuck.
Here's the current status of the game.Current keys. P1: LEFT, RIGHT, UP, DOWN + L as turbo P2: E, D, F, S + SHIFT as turbo u can try the shift+d+f combination to see what i mean. [Code]...
View 2 Replies