Moving an image-  defining the movement speed

Alright. I have the whole code set up to display the tiled image, and move the tiled image when you click. The only problem is that It moves however far it is told to instantly. I need it to move at a fixed rate of around 20~40 pixels a second. I haven't been able to figure out the exact numbers. Would I use a sleep timer for this? I'm completely lost at this point. Here's the important parts of the code, the rest isn't necessary for you to see what I mean.
Frame.java code -
public final void mousePressed(MouseEvent evt) {
          ix = evt.getX();
          iy = evt.getY();
          ux += midX - ix;//ux is static
          uy += midY - iy;//uy is static
     }Applet.java code -
public void drawApp(Graphics g) {
          for(int i = 0; i < 14; i++) {
               for(int j = 0; j < 23; j++) {
                    Image IMGTEMP = Toolkit.getDefaultToolkit().getImage("images/realtiles/tile_"+Map.map[i][j]+".png");
                    Map.mapX = ((j*24)+tileX)+Frame.ux;
                    Map.mapY = ((i*24)+tileY)+Frame.uy;
                    g.drawImage(IMGTEMP, Map.mapX, Map.mapY, this);
                    redraw(true);
     }When i click say, at 400px, 200px, it subtracts that from the midpoint, which is 250,175, and returns the x value of -150, y value of -25. Then it moves each tile -150x and -25y, making the point you clicked at the midpoint.

You need to define xspeed and yspeed
When you click, your speeds are gonna be
xspeed=(mouse_x-x)/30;
yspeed=(mouse_y-y)/30;Then in your run() method (assuming you have a run method) you do
public void run(){
while(true){
x+=xspeed;
y+=yspeed;
Thread.sleep(30);
repaint();
}

Similar Messages

  • Defining the movie edges

    I apologize if this is ridiculously simple to answer; I
    created a movie that works fine in Flash Player, but in the browser
    window, the "edge" of the movie is not eliminated, i.e., if I move
    an object on or off stage, the object is not masked to the stage.
    I've tried searching on this but am getting lots of off-topic
    material and nothing that addresses this. Is there a way I can
    define exactly what is on screen and what is off?
    Thanks

    did you publish with the 'transparent windowless' feature on?

  • Making a loaded swf-file loading images into the movie..

    Trying to convert my problem from norwegian into english
    isn't always that easy... :)
    Anyway..
    I've created som cool buttons that I want to be loaded into a
    movie (let's call i MainMovie.swf) and from there I want the
    buttons to be able to load images into a movieclip (ImageContainer)
    inside the MainMovie.swf.
    Is it possible to make the MainMovie.swf communicate with the
    the loaded buttons (each button is a swf-file containing the
    actionscript, objects, etc.) so when the buttons are clicked they
    load different images into the ImageContainer?
    My idea here is to include an as.file into the MainMovie.swf
    as well containing the url's to the images that I want to be loaded
    into ImageContainer.
    I've tried to create a button on a layer above the buttons
    that's loaded into the MainMovie.swf but I end up with the loaded
    buttons not working properlu because of the button that I've
    created and placed above them.
    Now, I don't want the url's inside the buttons thats loaded
    into the MainMovie.swf as I want the ability to be able to replace
    those buttons-files without having to use too much time writing the
    url's in each button.
    Thanks folks.

    are all your swfs using as3 or as2? if as3, you won't be
    loading into a movieclip: you'll use a loader instance and you can
    reference (or communictae with) the loaded as3 objects using the
    content property of your loader once you cast it as a
    movieclip.

  • How do I change the "Q" icon in my files folder to the first image of the movie like my .avi files?

    How do I change the "Q" iconin my file folders like I have for my .avi files?  I have Windows XP and have just purchased a new Nikon camera.  All video files are imported as Quicktime and it is frusterating to see what the video is without having to open all of them. 

    Just do:
    setIconImage(Toolkit.getDefaultToolkit().createImage(YourFrame.class.getResource("your_icon_file")));
    Abraham

  • Why is my image showing up as a clip of 8 repeating images, rather than a single image?  It does not show up 8 times in the movie, only in the editing screen as a clip with torn edges.  This hasn't happened before.

    In the past, when I moved an image from the frame where I would store all the media I may want to use in a particular project, to the upper frame where you create the project, the image would only show up as a single frame.  Now, it is showing up and looking more like a video clip, repeated 8 times and with a "torn edge" at the end.  When I play the image, it only shows up a single time.  I am not able to edit each frame individualy.  The Ken Burns icon only appears in the upper left corner of the first image.  I must have accidently changed a setting somehow, but don't remember doing this.  While the quality doesn't seem to be affected, it is taking me much longer to go back through the images and crop/fit them. 
    I am using imovie '08 and would consider myself an extreme novice. 

    I should clarify, when I meant I can only edit the first image, I don't mean only the first image of the project, but rather the first image of the 8 repeats. 
    I should also add that the project didn't begin this way.  I added enough images and then put the first song on.  When I started adding the photos that would be shown as the next song played, that is when they showed up as repeats of 8 AND all the previous images did the same.  That is why I am thinking I changed a setting when I added the music, but if I did, it was done accidentally and I can't seem to back track and find what I did.

  • Quicktime movies corrupting randomly.  "The movie could not be opened."

    Hello,
    Has anyone else encountered the Quicktime error where you have a perfectly functional file stored to a disk and then randomly, the file's icon will change from a still image from the movie to just the generic Quicktime file movie clip icon and then if you try and open the file you get the following error message:
    The movie could not be opened.
    The file is not a movie file.
    Nothing was done to the file. Nothing was done to the disk. This can happen when no one is even using the computer. Once it happens, the file will not open or play at all. It just returns this error message. I've only seen this so far happen on ProRes HQ files. Doesn't matter if they are HD or SD. It is infuriating and is costing my facility a ton of money and time and making us seriously reconsider using Quicktime.
    The only resource I've been able to find online that seems to be able to deal with this is:
    http://aeroquartet.com/movierepair/repair.html
    However, because of the nature of the content that I work with I cannot send a clip out of house for repair and cannot pay $89 per file (starting price). I would really like to see a response from someone at Apple as to why this is happening and what fixes are in the works to prevent it.
    Thanks.

    To Apple Discussions!
    What type of files are they - .avi, .mp4, .mov, etc.?
    Make sure you have the following installed:
    Flip4Mac
    VLC Media Player
    Perian

  • Blur filter missing when publishing the movie

    In one movie I use some blur filter on a movie clip. I see
    the effect when I play the timeline directly inside flash (by
    pressing enter). But when I "Test movie" or publish the movie the
    blur filter is gone.
    I have encoutnered this problem twice now and I don't know
    why this is happening. I usually do not have this problem but
    suddenly the blur-filter stops working.
    Publish settings are correct what i can see (version: Flash
    Player 9 )
    Anyone encountered the same problem?

    Ok, I found out what the problem was. Im having a png-image
    inside the movie clip I use the blurr filter on. And it seems like
    there is a size-limit on the image when you are using filters. I
    made the image a bit smaller and the blur came back and then made
    it bigger and bigger in steps and just before I reached the
    original image size the blurr filter stopped working again. I don't
    know if the limit is on the pixel size or the kb of the image, but
    some sort of size limit is there.

  • The internet speed is dropping to zero in every fe...

    The internet speed is dropping to zero in every few seconds. The image is the utorrent speed chart.
    Also during the outage the bt router web page is not coming. It is acting just like a switch -on-off-on... very frustrating.
    system info
    Model:
    2701HGV-C
    Hardware Version:
    2701-100630-009
    Firmware Version:
    6.3.9.63-plus.tm
    MAC address:
    b8:e6:25:35:2f:e8
    Key Code:
    528Y-27G4-A222-22BJ-B22V
    First Use Date:
    September 3, 2013
    Current Date & Time:
    Saturday, November 9, 2013
    5:13:13 PM
    GMT Standard Time
    Time Since Last Boot:
    0 day 1:15:40
    System Password:
    Custom: ******
    Manufacturer:
    2Wire, Inc.

    unless you are on a totally unlimited package P2P protocols are throttled at peak times have run the further diagnostics section of the BT Speedtest http://speedtest.btwholesale.com/ the further diagnostic testst appears after the first test completes
    If you want to say thanks for a helpful answer,please click on the Ratings star on the left-hand side If the reply answers your question then please mark as ’Mark as Accepted Solution’

  • Can an image in the slideshow widgets be moved around inside the bounding box as can be in a normal image placed into Muse (double clicking on a placed image gives the functionality to move the image around - as per Indesign functionality)

    Can an image in the slideshow widgets be moved around inside the bounding box as can be in a normal image placed into Muse (double clicking on a placed image gives the functionality to move the image around - as per Indesign functionality)

    Can an image in the slideshow widgets be moved around inside the bounding box as can be in a normal image placed into Muse (double clicking on a placed image gives the functionality to move the image around - as per Indesign functionality)

  • How can I choose the target image in Magic Move?

    Hello,
    I'm trying to use Magic Move to transition between slides. There are multiple shapes that are the same size and color on the target slide. Is there a way to control what the "target" shape is in Keynote?
    Here's what I mean (please pardon my corniness):
    Could I make it so that this image "shrinks" into the box on the far right ("Already")?
    Right now, it's defaulting to the third box from the left each time.
    Thank you so much for any help!

    Hello HanktheCat,
    Thank you for providing the details of what you are trying to do with Magic Move in Keynote.  I found a couple of resources that I think might help. 
    To use Magic Move, you set a target location by moving the original object to a new location or changing the size on the following slide.  I found an article with some tips on how to set this up:
    The Magic Move transition uses graphics and text that appear both on the current slide and the following slide. During the transition, the objects are moved into their new position and size on the following slide. This transition only works when you use an identical image, shape, or text box in a different location or with a different size on the next slide. Magic Move doesn’t work with tables, charts, or movies.
    For best results with a Magic Move transition, duplicate the slide and apply the Magic Move transition between the original and the duplicate.
    To set up a Magic Move transition:
    Create a slide and place the objects (text, shapes, images) where you want them.
    Select the slide in the Slide Navigator and press Command-D to duplicate the slide.
    On the copy of the slide, reposition and resize some or all of the text, shapes, and images on the slide.
    Add any additional text or graphics you want to add to the copied slide, and delete any objects you don’t want on it.
    Select the first slide of the pair and apply the Magic Move transition. For detailed instructions on how to add a transition between slides, see Adding Transitions Between Slides.
    You can find the full article here:
    Keynote '09: Tips for Creating a Magic Move Transition
    http://support.apple.com/kb/PH6129
    You can also watch a video of implementing Magic Move in this article:
    Keynote '09: Animate Objects Between Slides with Magic Move
    http://support.apple.com/kb/VI119
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • How do I substract an image at the time t with an image at t-1 to detect move in a grab acquisition

    After the VI acquire in a grab acquisition, how do I substract an image at the time t with an image at t-1 to detect the movement in the scene?

    Hello,
    One way of doing that is to do a ring acquisition with two buffers. At anytime one of your buffers will be the most current frame and the other will be one before the most current. Having both buffers available at anytime in your code you can call IMAQ Subtract.
    Hope this helps!
    Yusuf C.
    Applications Engineering
    National Instruments

  • PS CS5 Extended on Windows -  When trying to use the clone stamp and/or healing brush as soon as I move the cursor over the image I get an exact copy of the existing layer that moves around the window with the movement of the clone stamp/healing brush.  W

    PS CS5 Extended on Windows
    When trying to use the clone stamp and/or healing brush as soon as I move the cursor from the toolbar over to the image I get an exact copy of the existing layer that moves around the window with the movement of the clone stamp/healing brush.  This just started tonight.  What's causing this weird behaviour?

    What are the settings in Window > Clone Source?

  • How to have multiple images on the same screen? like in the movies where you see several actions at

    how to have multiple images on the same screen? like in the movies where you see several actions at the same time ....
    i don't find  a tutorial in adobe tv....
    thanks !!

    The short answer is that you'll put the source clip(s) for each inset on a different video track, all stacked up. Then use the Scale and Position effects (under "Motion" on the Effect Controls panel) to reduce their size and place them where you want.
    If the content of an inset will involve edited content (where you're cutting among various clips or just trimming out unwanted content from a single clip), then you'll probably find it easier to do all those edits in one sequence, then nest that sequence in the master sequence, where you apply the Scale and Positioning effects. That will save the step of applying the scale and position effects to each edited track item.

  • How do I use the move tool in CS5 to put two images on to an A4 sheet?

    Have recently upgraded from CS3 to CS5.
    I often print out two images on A4 paper.  Under CS3 I would simply adjust and crop 2 images to say 7 ins x 5 ins, after that bring up a new A4 sized sheet (file, new), then using the move tool I'd move the two separate images on to the A4 sheet and print.  Fine!
    Now under CS5, once I've adjusted my first image then try to bring up a second image to adjust that one I seem to lose the first one from the screen.  But on going back via Bridge and clicking on the image it re-appears - problem is, I lose the second image.
    When I bring up a new A4 sheet neither of the images stay on the screen and there is nothing to move.
    Have been into Preferences to see if there is anything there to help but can't see anything.
    Does anyone know what is happening here and what I'm doing wrong i.e. how do I get 2 separate images on to an A4 sheet?
    Thanks,
    Bob Eveleigh.

    There have been changes since cs3, mainly that cs5 uses tabs.
    Tabs can be confusing if your coming from cs3.
    If your in the tabbed mode, try going to Window>Arrange>Tile.
    All your open documents should be visible on the screen.
    If this is the cause of your frustrations, you can read more here:
    http://help.adobe.com/en_US/photoshop/cs/using/WS8599BC5C-3E44-406c-9288-C3B3BBEB5E88.html #WS6389D09B-91D5-4474-9AED-C52AE33356EB
    MTSTUNER

  • How to define the query condition of Image Theme in MapBuilder?

    Hi,
    I'm trying to add an dynamic Image Theme in OracleMap, but there's a problem.I defined the query condition of Image Theme like this:
    select scanimage,shap from image where scanimgid=467
    The shap column is the MBR column
    And the XML CODE:
    <?xml version="1.0" standalone="yes"?>
    <styling_rules theme_type="image" image_column="SCANIMAGE" image_format="JPEG" image_unit="M" image_resolution="1.0">
    <rule>
    <features> select scanimage,shap from image where scanimgid=467 </features>
    </rule>
    </styling_rules>
    When i preview this Image Theme ,there is an ORA-00936 error means lack of expression.
    Is there any problem with my definition?Or can query an image from an Image Theme?
    Thanks a lot for your help!
    Message was edited by:
    N.Mars
    null

    Hi Mars,
    predefined image theme definition does not support a "select" statement in the <features> tag. You should just define a query condition in the <features> tag.
    It seems that you are trying to use an image theme in Oracle Maps, but it currently does not support a FOI image theme. You should add a predefined image theme as part of the basemap, and maybe add scales values to set the visibility range of this image theme.
    Joao

Maybe you are looking for

  • Where can I get a replacement for my IPOD's USB cord?

    Today at work while I was charging my IPOD I noticed that the USB cord was coming out of one of it's ends and was not charging the IPOD correctly. So I was wondering where can I go just to get a new USB cord for the Nano? My husband said to just use

  • Lightroom 5 and Lens Correction-issue

    Hi, sometimes in LR4 I used the lens correction. Most pictures nowadays I take with an old NIkon 24-85:2.8-4 lens. When I tick lens correction and choose as manufacturer Nikon it automatically gave me the Nikon 24-85:3.5-4.5 (as the 2.8-4-version is

  • How to listen to key press in JTable

    I've been trying to listen to key press in JTable, However it only works if the cell is double-clicked. If the tab button is use or the cell is single-clicked, nothing happens to the listener. Anybody can help me??? Thanks

  • How to call different templates from EBS 11i?

    Hi, I have three templates having same layout but different page width and heigth. How can i call these three templates conditionally from main template in EBS. Need urgent help Thanks, Mahesh

  • Interested in finding out about using LabView in Networking Testing applications.

    Networking Testing applications, such as: - General Ethernet and POS testing - BERT - RFC2544 back to back, Frame loss, Throughput - RFC2285 - IP Multicast - QoS - Load Balancing - Wireless IP - BGP - Other Networking testing