Character movement needs fine tuning

This the code to move my hero mc around the screen.
However, when you click directly under or over the mc it doesn't move. When I say directly above I mean the angle not the distance. ie: I am well above the mc but it doesn't move.
Little kids are going to play this and it needs to be more responsive or they get frustrated.
var speed:Number=.99;
public function onEnterFrame(event:Event):void {
var xDistance:Number=clickPoint.x-this.hero.x;
var yDistance:Number=clickPoint.y-this.hero.y;
if (Math.abs(xDistance)>10) {
var angle:Number=Math.atan2(yDistance,xDistance);
this.hero.x+=v*Math.cos(angle);
this.hero.y+=v*Math.sin(angle);
} else {
this.hero.gotoAndPlay("static");
enemy1.x = speed*enemy1.x+(1-speed)*hero.x;
enemy1.y = speed*enemy1.y+(1-speed)*hero.y;
if (clickPoint.x>=hero.x) {
this.hero.gotoAndPlay("right");
//trace(Math.abs(xDistance));
if (this.hero.x>=clickPoint.x) {
this.hero.gotoAndPlay("left");
//trace(Math.abs(xDistance));

You're not moving because your x offset is less that your required 10 pixels.  So even though your y IS, you're not considering it.
var xDistance:Number=clickPoint.x-this.hero.x;
var yDistance:Number=clickPoint.y-this.hero.y;
if (Math.abs(xDistance)>10) {
      var angle:Number=Math.atan2(yDistance,xDistance);
      this.hero.x+=v*Math.cos(angle);
      this.hero.y+=v*Math.sin(angle);
} else...
You need to caluculate the actual distance between the position of your character and the mouse click, not just on one axis.
Try this:
var distance:Number = Point.distance(new Point(clickPoint.x, clickPoint.y), new Point(this.hero.x, this.hero.y));
if (Math.abs(distance) > 10) {
     var xDistance:Number=clickPoint.x-this.hero.x;
     var yDistance:Number=clickPoint.y-this.hero.y;
     var angle:Number=Math.atan2(yDistance,xDistance);
     this.hero.x+=v*Math.cos(angle);
     this.hero.y+=v*Math.sin(angle);
} else {
     this.hero.gotoAndPlay("static");
There's no need to calc the x and y distance if your total distance isn't enough to move your character, so just moved that into the conditional.
Hope it helps.

Similar Messages

  • Program times out while looping at internal table with huge records - Needs fine tuning suggestions

    Hi,
    I am trying to execute a report. It times out while looping at vbap internal table. This internal table has 140000  records and does the validation within this loop and geenrates data for the output. Due to this huge volume, the program times out when executed foreground.
    There are no nested loops, so I cannot apply 'Parallel Cursor' here.
    Is there any way I can fine tune the program so that it doesn't timeout? Is it possible to apply 'Parallel Processing' . If yes, how?
    Thanks,
    Pavan

    Hi Pavan ,
                  ->sort your internal table by all primary key for vbap.
                  ->Read a Record from the table (use your condition here)
                  ->if record satisfys your where condition ,get that record index .
                  ->loop the table from the index (without condition) .
                  its like parallel cursor only but for single loop .;-)
                  ->use field symbols ,wherever possible .
               if still dump is coming ,contact your basis team .
    regards,
    Krishna.

  • Fixing Radio: Fine tuning songs (Hits, Variety or Discovery Mode)

    Our radio has always been weird, you never know what songs it plays, and it always REPEATS THE SAME GOD darn SONG over the past hour.
    It's time to fix it. 
    If you've tried, or at least clicked into an app of a competing service, this is how it looks like:
    You can kinda tune the station to WHAT YOU LIKE, for eg, Hits, Variety, or Discovery and the radio will adapt what you want to hear.
    Here's another example (A not very solid example though):
    As you may know, Echo Nest is now a Spotify company, anyway, this shows the radio where you can slide to whether artist only or discovery in general (This might not be a good example, as if I just wanted to listen to the artist, I would've just went into the artist page and click on Shuffle Play.)
    Here's another example:
    This is a relatively new music service, but if you've tried its radio, you wil find out that its really really spectacular. You can tell the service what is your mood and it plays songs based on that, but if that's not enough. It actually has brand new algorithms that is built just for this, I read somewhere that it even monitors your location, the songs you play in that location/event, the volume the song is playing and when you hit the radio mode, it will analyze all of this algorithms and play based on that.
    So the radio needs improvements in its really bad algorithms and a fine tuning option.
    PS: If you go the comments section of this idea, in page 2,  bought up a really good visual of a competing music service vs Spotify when using the radio, if you've time you should take a look and if possible share more of the problems that you face with Spotify Radio.

    "Improving Station" is a joke.  I have a station based on Laura Nyro.  I keep getting the same very popular Nyro songs (but even that rarely) and some other 60s, 70s, 80s female vocalists.  Nothing newer.  I also get a ton of stuff nothing like Nyro, including male vocalists and male bands.  How many times do I reject anything of Elvis Costello before you stop playing it?  Same for many other artists.  You really need to track that if someone has rejected every one of an artist, quit playing that artist. Or, better, provide as has been suggested elsewhere here, a button "reject artist."  I've nothing against Costello, or Lightfoot, or the Doobies, or Bread, or many of the artists you put forth on my Nyro station.  I just don't want anything besides lilting female vocalists on my Nyro station.  (As well as much more Nyro.) Your learning algorithms are a joke, song by song is useless-- I have to come running back to the computer to keep rejecting stuff, even though I've been trying to "improve" the station for weeks.

  • Fine tuning with 3D roatation tool?

    Hi,
    I'm wondering if there is (and I feel there HAS to be) a way to fine tune movements with the 3D rotation tool. Using the mouse works to an extent, but just like nudging movements with the arrow keys, it's sometimes impossible to get the placement I want with mouse dragging. I'm pretty new to using these tools so maybe it's super obvious and I'm missing it?
    Thanks!

    Use the Motion Editor to do some great fine tuning. You can adjust each property separately and it will give you much better control.

  • TS3356 I have compiled my movie and I downloaded it into iphoto.  I then transfered it to imovie.  The movie shows fine, but when trying to export it to facebook, the share menu does not highlight.  Any help would be appreciated.

    I have compiled my movie and I downloaded it into iphoto and then transfered it to imovie.  The problem is that the movie plays fine, but will not highlight on the

    You may be attempting to Share (export) the movie from the Event Library. You need to create a Project, drag clips (or segments of clips) from the Event to the Project, then use the Share menu to export the Project. Movie clips can't be exported directly from the Event. Clips you add to a Project reference (point to) the clips in the associated Event (or Events).
    For more information, see the following iMovie Help topics:
    Start a new video project -
    http://help.apple.com/imovie/#mov3a61ee67
    Add video to a project -
    http://help.apple.com/imovie/#mov3a62377a
    The Help topics are also accessible from within iMovie. Click on the iMovie menu item "Help>iMovie Help".
    John

  • Batch edge sharpen or customized sharpen in RAW fine tuning

    Do you apply a mild edge sharpen to all your pictures by default or have tweaked the sharpening default default in the 1.1 RAW fine tuning to your likeness or simply stick with the default in the RAW converter and just apply different amount of edge sharpening on an image by image basis?
    Peter
    Quad G5   Mac OS X (10.4.8)   GT 7800

    Thanks William.
    My question was not primarily, whether you use the defaults for edge sharpen.
    Let's explain it a bit more detailed:
    Almost all pictures from DSLRs need sharpening to some extend. That basic sharpening usually is done in the RAW converter and can be adjusted with the RAW fine tuning since Aperture 1.1
    Since Aperture 1.5 we have the new edge sharpen tool, which is said to give much better results than the old sharpen tool. Looking at the sliders I assume, the sharpening in the RAW fine tuning is done with the same algorithm that is used in the old sharpen tool.
    So my idea was, whether it is probably better to trim down or even disable the sharpening in the RAW fine tuning and instead batch apply a small amount of edge sharpen to all my picture. Then tweak the edge sharpen on those pictures that need it.
    So far my approach is to use the sharpening in the RAW converter usually set to the Apple default and additionally apply edge sharpen for individual pictures, if I think they need it.
    Peter

  • Raw Fine Tuning - Custom Settings?

    Good Day
    I created custom settings in the "Raw Fine Tuning" palllete, I can't seem to change or remove them. Every new CF card I download automatically changes to this custom setting which I no longer want.
    I have tried to change these custom setting and save them as camera raw default, but it just goes back to the old custom settings. I have also tried to re-set to default setting, no go. Also tried to "select all" and change them back to the "apple" raw settings, only the primary image changes, "primary only" is turned off. Please help?
    thanks, shane

    leonieDF wrote:
    How do they differ after the last update? Ithink my Canon EOS 5D Mark II images now need less boost than before.
    I have speculated elsewhere that software and camera manufacturers are pushing hotter and more "Disney-fied" defaults than they have in the past (and that these have always been "unreal").  My experience with a Sony a77 is that the newest RAW upgrade reverses (or calms) this trend.
    The Sony a77 default setting under Apple RAW Compatibility Update 3 was too saturated and too contrasted (locally and globally).  I pulled back Boost to 0.7 and Hue Boost to 0.6, and left the rest the unchanged.  Under RAW Compatibility Update 4.0, I don't have to make as big a change, and settled on Boost=0.93 and HueBoost=0.70.  I also tweaked the other settings -- the biggest change there was putting moire to zero.
    That said -- I am having significant repeatable color problems with my NEC wide-gamut PA271W monitor, so I am going to have to revisit these settings after I resolve that.  I made the new settings based on the Retina display and an NEC 2490WUXi2.  They produce images that look great.  I have not printed any yet, but getting matching prints has not been a problem in the past.
    Do you change any settings other than Boost and Hue Boost?

  • De-Noise setting with custom RAW fine-tuning ?

    If I look at the De-Noise setting when using the Apple default you will notice that it varies with the ISO of the image (Njikon D4). As the ISO increases so does the De-Noise setting. This is often a good thing. If I save my own RAW fine-tuning setting with out touching the De-Noise setting and make it the Default, the De-Noise setting is no longer 'active' and just sits at zero for all ISO settings.
    How do we create a custom preset that will automatically increase De-Noise when the images have a higher ISO?
    JO

    leonieDF wrote:
    How do they differ after the last update? Ithink my Canon EOS 5D Mark II images now need less boost than before.
    I have speculated elsewhere that software and camera manufacturers are pushing hotter and more "Disney-fied" defaults than they have in the past (and that these have always been "unreal").  My experience with a Sony a77 is that the newest RAW upgrade reverses (or calms) this trend.
    The Sony a77 default setting under Apple RAW Compatibility Update 3 was too saturated and too contrasted (locally and globally).  I pulled back Boost to 0.7 and Hue Boost to 0.6, and left the rest the unchanged.  Under RAW Compatibility Update 4.0, I don't have to make as big a change, and settled on Boost=0.93 and HueBoost=0.70.  I also tweaked the other settings -- the biggest change there was putting moire to zero.
    That said -- I am having significant repeatable color problems with my NEC wide-gamut PA271W monitor, so I am going to have to revisit these settings after I resolve that.  I made the new settings based on the Retina display and an NEC 2490WUXi2.  They produce images that look great.  I have not printed any yet, but getting matching prints has not been a problem in the past.
    Do you change any settings other than Boost and Hue Boost?

  • TS3623 I have a 3rd generation Apple TV. I have purchased and/or rented numerous movies from iTunes previously. Last night we rented a movie, and we were unable to play it. The movie loaded fine; however, it is stuck on the 'Authorizing' screen. Help??!

    I cannot get rented itunes movies to play on my appletv. It keeps getting stuck on the "Authorizing.." screen. Movie loaded fine; however, would not start playing.  I have an ethernet cable plugged in, so wireless connectivity strength is a non-issue. Any suggestions??

    I have had this identical issue (on an Apple TV3) and was helped by Apple Support who guided me to go to the Settings Menu on the Apple TV and did a RESET. You will need to re connect to your WIFI and your iTunes account (passwords etc).

  • Using mouse to make fine tuning adjustment

    I have just installed Ligthroom 2.5 upgraded from Ligthroom 1.4; it appears that I can not longer make fine tuning of the ajustment using the mouse wheel but I am stock to move the slides by dragging them with the mouse or entering a value...
    is the mouse wheel capacity to make adjustement discontinued with Ligthroom 2.5; if not, how do I got about using the mouse wheel?
    Thanks,

    Thank you very much for the clear answers.
    Message for the adobe people, this is a major functionality lost (for an upgraded product) when ajusting for hundreds of picture this increase the time to make all the adjustment by many folds (which is my case). It would be worth investing time to fix the problem instead of removing a very important and useful fonctionality.
    Can anyone provide the specification for the mouse that would support such functionality as indicated by Ian?
    Thanks

  • SCOM fine tuning

    Hi, 
    i've basic question in system center world.
    i've deployed scom new installation with big workload all Microsoft products. once i imported Management pack, i received tons of error and notifications, servers status goes critical in about 18 server.
    how i can quick check and fix that, should i do that one by one or i can apply setting generally to do basic fine tuning and how i do that ?
    i red some and used most common report but i don't know i can disable all this events for time been.
    thanks, 

    Hi,
    Usually, you don´t want to import a lot of management packs at a time since they require different amounts of configuration and tuning once imported. If you haven´t done so, read the Mangaement Pack documentation that comes with every MP (or download the
    documentation if you´ve downloaded imported the MP´s from inside the SCOM console). Some MP´s requires almost no configuration while others requires a lot of configuration to function properly.
    There is no quick fix as you will have to tune the thresholds to better suit the needs of your organization. To find out what is wrong with each server, navigate to Monitoring -> Windows Computers -> Pick on of the crititical servers -> Righ click,
    choose Open and then Health Explorer.
    Inside the Health Explorer you will see what you have to do to that server but you really need to look through the Management Packs documentation, other wise you won´t get a proper monitoring.
    Regards,
    Daniel
    IT Consultant at Viridis IT

  • DVDPlayer not recognizing DVD. I have an IMAC (10.7.4) using DVDPlayer (vers. 5500.26.11) and will not recognize/play a dvd movie...it thinks it is a blank dvd.  The dvd movie plays fine on my Mac Book Pro (10.6.8) on the Pro's DVDPlayer (vers.5.4).

    IMAC DVD Player does not recognizing dvd movie . I have an IMAC (10.7.4) using DVDPlayer (vers. 5500.26.11) and it will not recognize/play a dvd movie...it thinks it is a blank dvd. The IMAC will play rented dvd movies.   The dvd movie plays fine on my Mac Book Pro (10.6.8) on the Pro's DVDPlayer (vers.5.4) abd in my external Sony DVD Player  The dvd move was made/burned on a PC.   Why will a dvd movie play on my Macbook Pro and not my IMAC?

    Hello:
    This is not an area I have much experience in......I rarely insert DVDs and I have never had a similar problem.
    When the DVD is in the drive (and DVD players is open) click on File>get disk info.
    Barry

  • How do I delete movies from iTunes library? I have moved them to the iCloud and now only seem to have the option to hide the icon in iCloud.  I am sure I chose poorly at the 'keep file' window.  Please help. My Brain hurts- 18   movies need to go-.

    How do I delete movies from iTunes library? I have moved them to the iCloud and now only seem to have the option to hide the icon in iCloud.  I am sure I chose poorly at the 'keep file' window.  Please help. My Brain hurts… 18 plus movies need to go….  Thank you.

    Instead of removing the music from the cloud or the iTunes library why not shuffle your music using a Smart Playlist which excludes the holiday music, or tracks that are not checked. For example, use this very simple Smart Playlist:

  • I bought a Sandisk Connect Media Drive, downloaded the app from iTunes.  Before iOS 8, movies played fine.  After iOS upgrade I can no longer play movies downloaded from iTunes to the media drive.  Anyone else have a similar issue?

    I bought a Sandisk Connect Media Drive, downloaded the app from iTunes.  Before iOS 8, movies played fine.  After iOS upgrade I can no longer play movies downloaded from iTunes to the media drive.  Anyone else have a similar issue?

    I checked with SanDisk's own online support and they indicate that they have notified Apple of the issue.
    According to SanDisk, the problem lies with Apple not having the iOS 8 version of the Safari browser having DRM decoding enabled that the Media Drive relies upon to decode and play iTunes DRM titles. Non DRM encoded videos will play in the browser.
    DRM audio is not effected as this is handled by the native iOS music app.
    As of the date of this post SanDisk have not been given a timeframe by Apple for this issue to be resolved.
    I hope that Apple resolves this issue quickly as I have a large collection of DRM video titles on a 128Mb memory card installed in the Media Drive that I am unable to view.

  • To extend a clip I have `Show Fine Tuning controls' turned on in my iMovie 11 preferences, but the blue forward/backward buttons don't appear.  To get the orange handle bar, is there a hotkey?

    To extend a clip I have `Show Fine Tuning controls' turned on in my iMovie 11 preferences, but the blue forward/backward buttons don't appear.  To get the orange handle bar, is there a hotkey?

    That's a comment in the file. It has no effect at all.

Maybe you are looking for