PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Basic First person shooter code help
A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Basic First person shooter code help

Hybrid View

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    11

    Basic First person shooter code help

    Hi folks,

    I due to illness decided to try my hand at something new, making basic games. My son has cerebral palsy and the games and programs to suit these kids needs is pretty crappy, so I thought if I could learn to make games, and having a child and understand the needs, that maybe I could get to a point where I could help one day.

    I was advised from reading online that a basic sniper game is a good introduction, so I decided to start there.

    I am using Flash Mx 2004 and I am really new to everything, so please bare with me.

    The cross hair code I used is working, and it is as follows.

    onClipEvent(enterFrame){
    Mouse.hide();
    this._x=_root._xmouse;
    this._y=_root._ymouse;
    }

    I have 3 layers,
    1st is cross hair
    2nd is target
    3rd is scene

    So I went to the third layer and drew in some basic buildings.
    I then went to the target layer and created a stickman to shoot at.
    After creating the stickman I selected him and hit F8 to create a movieclip. I then doubled clicked on the stickman

    I then enter in new key frames with the target starting to fall on frame two and on the ground in frame three.
    I then inserted a frame into slot four to finish.

    On frame one and frame four I put the following.
    stop();

    I then on frame one turned the stickman I drew into a button
    and entered the following script.

    on(press){
    gotoAndPlay(2);
    }

    From this point apparently you can ctrl enter and you should be able to shoot the stickman, but what I get is the crosshair layer and if I use it on full screen I can move the cross hair all the way to the right and just see the scene I created.

    SO basically it is if the crosshair layer is blocking out all of the other layers behind.

    The tutorial I did shows the game working at this stage, but for me I get the above error.
    I have done the tutorial from start to this point twice now. I can't work out what I have done wrong.
    Any ideas? As I really want to learn where I went wrong so I can fix this.
    I was hoping to eventually add in multiple targets in case that makes a difference to the answer?

    Cheers.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Hi,

    I am really unsure about why it's not working as I haven't seen your FLA file, so maybe if you could post it here, I'll get a better understanding of the problem

    As for "unwanted" being shown when you turn it to fullscreen, you have to manually controll all elements with coding to make it look right even in fullscreen, but that's not an option for you (as you're new to this). Flash games aren't really meant for fullscreen, as CPU-intensive games would lag when in fullscreen, but you can always stretch the whole stage to fit as the game's size, by using this code on your Frame:

    Actionscript Code:
    Stage.scaleMode = "exactFit";
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Aug 2012
    Posts
    11
    ok, this is the fla file. It will probably be something simple, but can't work out what.

    thanks for your help.
    Attached Files Attached Files

  4. #4
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    761
    your top layer must have some alpha in it to be able to see through it
    [SIGPIC][/SIGPIC]

  5. #5
    Junior Member
    Join Date
    Aug 2012
    Posts
    11
    Thanks, but what does have 'alpha' mean?

  6. #6
    Dignitary rynoe's Avatar
    Join Date
    Jan 2003
    Location
    Earth
    Posts
    761
    see threw

    I have cs6 so can't see fla...
    [SIGPIC][/SIGPIC]

  7. #7
    Junior Member
    Join Date
    Aug 2012
    Posts
    11
    I will get cs6 and start again I think. Maybe even use a different tutorial. Still bugs me as to what I did wrong, but maybe I will work it out if I start again.

    Nig 13, if you are able to open the file and tell me where I went wrong I would appreciate it as I want to learn from mistakes so I am not destined to repeat them.

    thx

  8. #8
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    Hi, your crosshair symbol is a bitmap image with white pixels in between the crosshair circles.

    You either need to open it in photoshop and select the white pixels in between and delete and save as a PNG with transparency or recreate it in Flash. I would recommend the latter, it would be very simple just use the Oval tool (Keyboard O) and make a circle with no fill and copy the outline and use the Transform tool with width/height constrained to make it 50% of the original.

    As for alpha, it refers to the transparency of an object. Alpha 0 is invisible and alpha 100 is visible. To change the Alpha of the black background of the crosshair, select the background and in the color fill properties, there is a text field with Alpha, usually set to 100% be default, change it to 75% and you should be able to see the scene through it.

    Hope that helps and good luck. BTW, clicking the stickman enemy worked and played through animation. I would change your frame rate though for smoother animation, 24 fps over 12 fps.

  9. #9
    Junior Member
    Join Date
    Aug 2012
    Posts
    11
    Thanks heaps for that! I made te crosshair in photoshop as i know that program being a pro photographer. I had issues as i made it on a white background so i made the outside transparent but middle didnt even occur to me for some reason.

    I knew it would be something stupid i had missed.

    Thanks heaps!

  10. #10
    Junior Member
    Join Date
    Aug 2012
    Posts
    11
    Stephen,

    not sure if my last msg worked, is with the moderators atm anyway. I was using my iphone so not sure how that worked.

    just wanted to thank you for the help. It is greatly appreciated.
    I am going to assume to add a secondary target the enemy script would change from the simple script I am using. That is my next step to learn I think.

    Thanks heaps though.

  11. #11
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    No problem, Siege. I'm glad i could help. For the secondary target, its up to how you have it setup currently and how you want it later on, that will drive your coding.

    If you only have a few enemies, you can just copy the code for the other enemies.

    If you have a larger amount, you should use a FOR loop to add the code to all the different enemies dynamically.

    Like i said, it depends on your intentions, a lot of enemies or just a few per level. If you need further help just post here, or pm me. If it is a different topic, i would start a new thread though. I'm usually around the forums and check updates daily.

  12. #12
    Junior Member
    Join Date
    Aug 2012
    Posts
    11
    I guess my answer is a little bit of both, don't want to jump in too fast that you get lost and frustrated, but also want to progress to much further then a basic first person shooter game.

    I was planning on making a few levels just to repeat what I have learnt and was going to have no more than five targets per level.

    What I wondered though is if you have a target on keyframe 1 and you shoot that target and the script is told to go to keyframe two in which you have the target dropping to the ground, if you have five targets set up all the same does shooting one target activate them all so one shot five kills?

    The only other thing I would be interested in investigating at this point would be a way to zoom in and zoom out just to add some more depth to the levels.

    lots to learn.........

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center