Rotating guns and shooting them at the same time?

I put the registration point as the gun's arms. So then the gun would rotate from the arms. But then the bullets come out from the registration point as well. So if I make the registration point on the barrel of the gun, the gun would rotate from the barrel and then shoot from the barrel. So I'm a bit confused where is the right place to place the registration point.
Now what I want would be: Shooting the bullets from the barrel, not the arms. And also rotating by placing an axis on the arms, not the barrel. At the same time.
I tried tweeking it like, bullet.x = x - 100 to make the bullet placed on the barrel and come out from there, but if i rotate let's say (180 degrees) it shoots from the from x - 100 but then the gun is on the other side, so the bullet wouldn't be coming out from the barrel anymore.
I also tried tweeking it by adding a movieclip INSIDE the movieclip gun's barrel so the bullets would come from THAT location, but it shot bullets weirdly and not in the right position.
here is my code, is there any modifications i can put? so it can shoot from the barrel regardless of rotating the gun and changing positions, and also rotate from the arms at the same time? if there is any other solution to tweek it, thanks a lot.
  function initialize(e:Event)
   //add a click listener to the stage
   stage.addEventListener(MouseEvent.CLICK, fire);
  function fire(m:Event)
   //spawn a bullet
   var b = new Bullet;
   //set the position and the rotation of the bullet
   b.rotation = rotation;
   b.x = x;
   b.y = y;
   //add the bullet to the parent object
   parent.addChild(b);
   //play the firing animation
   play();
  function update(e:Event)
   //make the gun face the mouse
   if (parent != null)
    var dx = parent.mouseX - x;
    var dy = parent.mouseY - y;
    var angle = Math.atan2(dy, dx)/Math.PI * 180
    rotation = angle;
Thank you for reading, sorry if it was long.

For some reason, the gun's bullets still come out from the registration point. The registration points are on the arms, the gun is facing right and the barrel is at the end of the right.
But I tried this code but the bullet comes out from the same place of the rotating axis. I tried playing around with the code but no possible solutions.
Thanks.
EDIT: Also, if I put
b.x=platform.x+Math.cos(gun.rotation*Math.PI/180)*gun.length;  // where platform is the parent of the gun (assuming your gun is attached to a platform like a tank).
b.y=platform.y+Math.sin(gun.rotation*Math.PI/180)*gun.length;
The bullet comes out from the platform's registration point. If I remove the platform part, it comes out from the gun's reg point.
Another thing, if I modify it like "length - 100", it will change it's position but won't follow the rotation of the gun like I stated above. If it shoots from a certain location., and then I rotate the gun a certain amount of degrees the bullet will shoot from that side instead of following the gun's barrel.
So I'm wasn't completely sure on how to fix this. Thanks again.

Similar Messages

  • Bash script: Rotate your wallpaper and SLiM theme at the same time

    EDIT;
    I've decided I should really thank Cerebral for his help with writing this script; this thank you should have been here from the get go.
    After writing:
    #!/usr/bin
    echo "Hello World!"
    I wrote a script to rotate my fluxbox background and SLiM theme at the same time, so I could have a contiuously changing background and still have a smooth transition from SLiM to fluxbox.  (It just looks so much cooler when both have matching backgrounds).  By the time you finish reading it, and configuring your box so it will work, you will probably have decided you could have writtin your own, better script to do the same thing.  But, on the off chance anybody finds use for it, here it is:
    (this should be obvious, but: don't run this script without at least reading the comments)
    #!/bin/bash
    #this is a script to rotate a number of backgrounds
    #to be shared by the fluxbox desktop and SLiM login manager.
    #it is the first meaningful script I've written. It may be
    #freely distributed and used with the understanding that you are
    #using it at your own risk.
    #Before running this script you need to check that your SLiM
    #themes are installed to the path /usr/share/slim/themes, which
    #is the defulat path for installation in Arch. Here are some
    #other things you need to set up:
    #1. create (if you don't have it) the directory /usr/share/wallpapers
    #2. create a wallpaper in /usr/share/wallpapers called 'dummy' by copying
    #you current wallpaper to that filename
    #3. set your window manager to display the wallpaper 'dummy', this works fine
    #using a style overlay in fluxbox, I haven't tested it with any other window
    #manager, but I don't see why this would cause a problem.
    #4. create a directory /usr/share/slim/themes/current, you can copy one of
    #your slim themes into that directory if you want. (this will prevent you
    #from seeing some error messages the first time you run the script)
    #5. define the names of the themes you want to rotate, in order for this
    #script to work, you must name them "themeNUMBER", where NUMBER is replaced
    #by an integer. Your themes must be numbered consecutively, start with 1
    # that is:
    #theme1 , theme2, theme3, etc. , theme305
    #If you don't number consecutively, this script will not run properly. You
    #must also define the total number of themes as "rotate_number"
    #6. Check if the script runs, if it does, you should change /etc/slim.conf to
    #use the theme "current"
    #7. This theme will now rotate your SLiM theme and wallpaper in such a way as
    #to make them match each other. Note that SLiM will not let you change themes
    #"on the fly", (as of July 6, 2008), so changes will not be apparent unless you
    #restart SLiM. I run the script before I run slim in my etc/rc.local local
    #script, so each time I reboot I get different wallpaper / login background.
    #Fred Drueck 2008
    #Define here all themes to be rotated and the total number of
    #themes to rotate:
    rotate_number=9
    theme1=/usr/share/slim/themes/default
    theme2=/usr/share/slim/themes/lake
    theme3=/usr/share/slim/themes/lunar
    theme4=/usr/share/slim/themes/flower2
    theme5=/usr/share/slim/themes/the-light
    theme6=/usr/share/slim/themes/mindlock
    theme7=/usr/share/slim/themes/parallel-dimensions
    theme8=/usr/share/slim/themes/wave
    theme9=/usr/share/slim/themes/fingerprint
    #check you are running this script as super-user:
    if [ $(id -u) != "0" ]; then
    echo "You must be the superuser to run this script" >&2
    exit 1
    fi
    echo "rotating themes"
    #figure out which theme is currently set, then name it as the variable
    #"last theme number", otherwise set last theme number as 0
    if [ -f /usr/share/slim/themes/current/current_theme_number ]
    then
    echo "checking current theme"
    cd /usr/share/slim/themes/current/
    eval last_theme_number=$(cat /usr/share/slim/themes/current/current_theme_number)
    echo $last_theme_number
    else
    echo "no theme is currently set, using theme 1"
    last_theme_number=0
    echo $1 > /usr/share/slim/themes/current/current_theme_number
    fi
    #set the new theme number
    eval new_theme_number=$(($(($last_theme_number % $rotate_number))+1))
    #select the new theme
    placeholder=theme
    eval new_theme=\$$placeholder$new_theme_number
    echo $new_theme
    #now clean out the "current" theme where I keep the current
    #theme for slim
    rm /usr/share/slim/themes/current/background*
    rm /usr/share/slim/themes/current/panel*
    rm /usr/share/slim/themes/current/slim.theme
    #the wildcards are there since the themes use jpg and png files
    cp $new_theme/background* /usr/share/slim/themes/current
    cp $new_theme/panel* /usr/share/slim/themes/current
    cp $new_theme/slim.theme /usr/share/slim/themes/current
    #increase the theme number, but first clear the old file
    rm /usr/share/slim/themes/current/current_theme_number
    echo $new_theme_number > /usr/share/slim/themes/current/current_theme_number
    #copy over the dummy wallpaper in "/usr/share/wallpapers" (with the theme
    #background file
    cp $new_theme/background* /usr/share/wallpapers/dummy
    exit 0
    Last edited by pseudonomous (2008-07-07 21:59:42)

    oh i forgot to mention... its rotating while moving. i.e. is doesn't have to stop rotate and then continue back to origin.

  • Can i add two country holiday on my iCal and see them at the same time?

    Can i add two country holiday on my iCal and see them at the same time? HOW?

    Just subscribe to the appropriate calendars: you can subscribe to as many as you like.
    http://www.apple.com/downloads/macosx/calendars/

  • HT1550 I'm having trouble with importing them into iTunes and converting them at the same time. when i hold down option over the files i can't find where its supposed to say create new version. is this if you're in iTunes?

    I'm having trouble with importing them into iTunes and converting them at the same time. when i hold down option over the files i can't find where its supposed to say create new version. is this if you're in iTunes?

    You can't do it in one step. Add to iTunes first, Once the tracks are in iTunes you may convert to a different format.
    tt2

  • IS there a way to load and purchase different photos from iPhoto and ship them at the same time? the only way that I can find is to purchase each photo (or multiple of one) at a time, which increases the cost of shipping, as I want to get one print of 20

    Is there a way to order multiple different prints in any quantity from Iphoto? it appears currently like I would have to ship each separately, even if only one print... is there a way around this so I can can get several DIFFERENT prints of any quantity and ship all at the same time?

    Sure - easiest way is to make an album for photos you want to order and drag photos to it - when it is complete open the album, select all and order
    LN

  • Why can i rotate screen and have sound at the same time.   Why is only option one or the other

    why cant i rotate and have sound at the sametime?  why does it have to be one or the other.   

    Do you really think it's not possible to do both and set them up the way that you want them to be set up? You just don't understand how the process works.
    System sounds can be muted and controlled two different ways. The screen lock rotation can be controlled in the same manner as well.
    Settings>General>Use Side Switch to: Mute System sounds. If this option is selected, the switch on the side of the iPad above the volume rocker will mute system sounds.
    If you choose Lock Screen Rotation, then the switch locks the screen. If the screen is locked, you will see a lock icon in the upper right corner next to the battery indicator gauge.
    If you have the side switch set to lock screen rotation then the system sound control is in the control center if you are running iOS 7. Swipe up from the bottom of the screen to get to control center . Tap on the bell icon and system sounds will return.
    If you have the side switch set to mute system sounds, then the screen lock can be accessed in the same manner as described above.
    This support article from Apple explains how the side switch works.
    http://support.apple.com/kb/HT4085

  • Logging, capturing and shooting all at the same time

    Hello,
    I have FCP 5 loaded on my MacBook Pro and trying to log, capture, and shoot at the same time.
    Here is my set up. I have my canon XL-1s recording to tape, also i have firewire running from the camera to the computer. FCP has the log and capture window open i receive timecode, picture and sound. I can log the clips as they happen and it gets placed in the bin.
    How can i have FCP capture "now" with an offline Photo JPEG compression, as i shoot?
    Thanks
    Eric
    MacBook Pro 2ghz   Mac OS X (10.4.8)  

    The firewire out from your camera must be captured using Capture Now. Unfortunately the file you capture will not have the same timecode associated with it as the tape - a massive pain if the need to recapture arises.
    In order to edit while recording, you need a hardware/software solution such as Picture Ready
    Not inexpensive, but if your project will support it ...
    good luck.
    x

  • I'd like to sync two videos and edit them at the same time, possible?

    I've recently recorded a conference speaker with a camera and a screen capture of his slides I'd like to import the two video files and sync them together (they received the same audio feed) then perform very basic edits of removing any intro before the speaker and the q&a after his talk. Any tips on making this as easy as possible would be greatly appreciated. I need to have a copy of each video (headshot and screen capture) that is the same length.

    Here is the user manual about creating and editing Multicam clips.
    http://help.apple.com/finalcutpro/mac/10.1/#ver23c76439
    macProVideo.com and Ripple Training have the best online training available.
    http://www.macprovideo.com/finalcut
    http://www.rippletraining.com/categories/apple-pro-apps-tutorials/final-cut-pro- x-tutorials.html
    The "Apple Pro Training Series: Final Cut Pro X 10.1, Professoinal Post Production" book is what we use to teach Apple authorized training, and is really quite good.  It is step-by-step, hands-on training you can't beat.
    http://www.peachpit.com/store/apple-pro-training-series-final-cut-pro-x-10.1-pro fessional-9780321949561
    I've found the Lynda.com FCPX training to be lacking, and it is not kept up to date very well.

  • Using the rotate tool and hand tool at the same time in CS6

    When using the rotate tool, you used to be able to use the hand tool even when the Rotate dialogue box was up. Is there a way to get that back?
    I make Mandalas (http://www.behance.net/gallery/Mandala/2700497) and work from the center out. This poster is 18"x24" so once I start to get to the outer edge, I'm zoomed into the center at 6400% so I can get my crosshairs as precise as I can, then enter a number (45 degrees, 20 degrees, etc.). Clicking Preview helps, but if you're zoomed in and the object is out of view, you have to guess where it's going. In CS5, you could press down the space bar and use the Hand Tool even while the dialog box was up. Is there a fix for this? (Sorry if this doesn't make sense...it's kind of hard to explain over a forum.)

    TBamber wrote:
    When using the rotate tool, you used to be able to use the hand tool even when the Rotate dialogue box was up. ....
    CS5 on Windows 7.
    I can use the hand tool while pressing the Space bar while another tool including the Rotate tool is current. But I can not use the Hand tool in anyway if I'm in the process of using the Rotate tool by holding down the mouse button or dragging with it.
    While the Rotate dialog is displayed I can not do anything outside of it in any way.
    I can use the scroll wheel on the mouse to scroll the view up or down vertically while using any of the tools including the Rotate tool but not when a tool dialog is open.
    I'm curious if others experience different behavior on a Windows system .

  • In Pages 5.2.2: How do you go from 1 column to 2 and keep them on the same page?

    In Pages 5.2.2: How do you go from 1 column to 2 and keep them on the same page?

    Sorry, I tried to say your answer solved my question, but I guess I told it that my response to you solved it. Now that I liked it, the solved option doesn't appear.

  • All of a sudden, my settings have been changed, my homepage, and EVERYTHING. No matter how many times I go in and change them again, the SAME pages open up when I start FireFox and I am constantly being asked if I want Yahoo as my start page and default s

    I don't know what happened. All of a sudden, my settings have been changed, my homepage, and EVERYTHING. No matter how many times I go in and change them again, the SAME pages open up when I start FireFox and I am constantly being asked if I want Yahoo as my start page and default search engine. I click the box 'do not ask me again' and it comes up EVERY TIME. I change things like I don't want history remembered, and when I reload FireFox again, it's back to the way it was BEFORE. EVERY SINGLE TIME. I don't know why this is happening, or how to fix it. What do I do??

    I do not want to download another virus program.. I do not believe it is a virus. I am running the full version of Norton 360 and it is doing a daily scan. I have Windows 7, 64 bit OS.
    This is very irritating !! If I wanted Yahoo I would ask for it !

  • I have family plan of 5 iphones and all them have the same apple id, the q. is how I can set each one with their own apple id? please advise...

    I have family plan of 5 iphones and all them have the same apple id, the q. is how I can set each one with their own apple id? please advise...

    See How to Stop Sharing an Apple ID.
    (Note that I am affiliated with that site, and some pages contain ads).

  • My ipad won't let me sign in to my FaceTime and iMessage and won't update my apps no more ever since I got my iphone and put them on the same account. Does anyone know how to fix it or why it's doing this

    II've had my ipad with retina display for about a 1 now and everything was fine In till I got my iphone 4s and put them on the same account then my ipad stopped letting me log in to my FaceTime and iMessage and it doesn't let me update my apps and dosnt let me log in to iCloud ever since I got my phone and put them on the same account does anyone know how I could fix it and still be able to connected to my iphone??

    Did you change your Apple ID?
    Unable to make or receive FaceTime calls after April 16, 2014
    http://support.apple.com/kb/TS5419
    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    iOS: FaceTime is 'Unable to verify email because it is in use'
    http://support.apple.com/kb/TS3510
    Using FaceTime and iMessage behind a firewall
    http://support.apple.com/kb/HT4245
    iOS: About Messages
    http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/
    iOS and OS X: Link your phone number and Apple ID for use with FaceTime and iMessage
    http://support.apple.com/kb/HT5538
    How to Set Up & Use iMessage on iPhone, iPad, & iPod touch with iOS
    http://osxdaily.com/2011/10/18/set-up-imessage-on-iphone-ipad-ipod-touch-with-io s-5/
    Set Up Alert Sounds
    http://www.quepublishing.com/articles/article.aspx?p=1873027&seqNum=3
    Extra FaceTime IDs
    http://tinyurl.com/k683gr4
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Troubleshooting iMessage Issues: Some Useful Tips You Should Try
    http://www.igeeksblog.com/troubleshooting-imessage-issues/
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
    Fix Can’t Sign Into FaceTime or iMessage iOS 7
    http://ipadtutr.com/fix-login-facetime-imessage-ios-7/
    FaceTime, Game Center, Messages: Troubleshooting sign in issues
    http://support.apple.com/kb/TS3970
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90
    iOS 7 allows you to block phone numbers or e-mail addresses from contacting you via the Phone, FaceTime, or Messages
    http://howto.cnet.com/8301-11310_39-57602643-285/you-can-block-people-from-conta cting-you-on-ios-7/
    How to Block Someone on FaceTime
    http://www.ehow.com/how_10033185_block-someone-facetime.html
    My Facetime Doesn't Ring
    https://discussions.apple.com/message/19087457#19087457
    How to watch FaceTime calls on the big screen with Apple TV
    http://www.imore.com/daily-tip-ios-5-airplay-mirroring-facetime
    Send an iMessage as a Text Message Instead with a Quick Tap & Hold
    http://osxdaily.com/2012/11/18/send-imessage-as-text-message/
    To send messages to non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
    How to Text on the iPad
    http://ipad.about.com/od/ipad_tricks/a/How-To-Text-On-The-Ipad.htm
    How to Send SMS from iPad
    http://www.iskysoft.com/apple-ipad/send-sms-from-ipad.html
    How to Receive SMS Messages on an iPad
    http://yourbusiness.azcentral.com/receive-sms-messages-ipad-16776.html
    Apps for Texting http://appadvice.com/appguides/show/apps-for-texting
    You can check the status of the FaceTime/iMessage servers at this link.
    http://www.apple.com/support/systemstatus/
     Cheers, Tom

  • How to record a USB mic and a guitar at the same time?

    I have an Audio-Technia AT-2020 USB mic and an Ovation acoustic/electric guitar. I wanted to record both of them at the same time, so i plugged the mic into the USB port (duh!) and the guitar into the 1/8" port on the computer (with a 1/4" to 1/8" adapter and a male/male headphone cable). However, when i went to select the inputs for the diffrent tracks, it was either one or the other. My question is, do you need an audio interface to be able to do multitrack recording? If so, could I use a USB hub, 1/8" to USB adapter, and plug both the guitar and mic to fool the computer into thinking i have an audio interface? I would rather not spend money on an audio interface ($200) and a new mic ($120) when i already have something that could work!
    Thanks to anyone who can help!

    beberhard14 wrote:
    do you need an audio interface to be able to do multitrack recording?
    create an aggregate device from the mic and line-IN:
    http://www.bulletsandbones.com/GB/Tutorials.html#allaboutaggregatedevices
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • How do I delete radio shows from iTunes and my iPod at the same time?

    I have a lot of old time radio shows on my iPod. First, I copy them from iTunes to listen to on my iPod. When I am done, I want to delete BOTH of them at the same time. I am trying to avoid having to search for both because, for some reason, I cannot search both the iTunes and the iPod content at the same time. I obviously do not want them synced. In the previous version of iTunes, I was able to do with a key command. Now, I cannot figure out how to do it. ( I really wish there was a way I could color each selection so that I can find which ones I copied to the iPod easily. You know, just like how it's done in the operating system, where we can add the color label.)
    Anyway, is there a way to do what I want, or am I stuck with searching separately, and then deleting them separately? Laborious indeed. Oh, yes, the duplicate function doesn't work here because you can't search both the iPod and iTunes at the same time.
    Thanks in advance to all you smartie-pants out there.

    when you purchas e a tv show from the itunes music store and then sync it to the ipod. there will appear a new name in th evideo subsection of videos on the ipod called tv shows thats where they will be and where you can watch the,.
    GFF

Maybe you are looking for

  • Reports 3.0 Printouts (Text Mode)

    1) We have been trying some printouts from the reports runtime by clicking on (Report Builder 3.0.4.6.3/Developer forms 5.0) the printer icon available on the menu bar and also specifying the appropriate print properties in the print dialogue box and

  • Calendar with Drill Down Report

    Hello, Everybody. I am new to Application Express. Please any one tell me step by step how to make calendar with drill down report. Waiting for valuable reply. Thanks Rahul

  • How to take input in one frame and display it in other frame of  same page?

    I need to take input (text) for the comment field in one of the frames and when submit button is pressed it should be displayed in the other frame on the same page. I am able to get the input from the user but its not reflected in the other frame whi

  • By the way, just tried to reboot like what other said to hold home button

    By the way, just tried to reboot like what other said, to hold home button & on/off button for 10 secs, no apple sign appears, screen stil stuck as it was ! ????

  • OWB login error

    I installed OWB 9.2.0.2.8 in my new machine and when I try to connect to the OWB Client, I am getting the following error: "API5022: Cannot connect to the specified repository. Verify connection information. Io exception: The Network Adapter could no