Results 1 to 4 of 4
  1. #1
    Markmywoods is offline Member
    Join Date
    Feb 2016
    Posts
    14
    Rep Power
    0

    Default Javafx make arc open and close while moving

    So I'm making a game similar to pac man and I'm wondering how do I make the mouth open and close while moving. I made the gobbler or pac man using arc. Using the methods arc.setStartAngle(-90)

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Javafx make arc open and close while moving

    I don't know if JavaFX has any special features to allow this but in Java you simply need to redraw the pac man while changing the gap. You should be able to do these two actions independently. First create a pac man that has a mouth opening and closing while not moving. Once you have that, then just call the paint routine with x,y coordinates to provide motion.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Markmywoods is offline Member
    Join Date
    Feb 2016
    Posts
    14
    Rep Power
    0

    Default Re: Javafx make arc open and close while moving

    I have one thats open and one thats closed how would i use the paint method to make each one keep switching back and forth to give off the open and closing of the mouth animation

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Javafx make arc open and close while moving

    You simply need to continue repainting the pac man in the same place. But you will need to do some tweaking. For example, you will need to slow down the movement so it can look likes it is opening and closing. And you may decide you need to have several images in various stages of the mouth being open. Think about how cartoons used to be drawn. One cel at a time. The successive displaying of the cels gave the impression of motion.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Save, open, close, etc. structure in java program
    By Karlovsky120 in forum AWT / Swing
    Replies: 3
    Last Post: 07-20-2013, 04:36 PM
  2. how to make jar file for javafx in eclipse?
    By sandeep43 in forum JavaFX
    Replies: 1
    Last Post: 05-10-2012, 08:44 AM
  3. Close a JFrame, but keep the original open.
    By nolsen01 in forum AWT / Swing
    Replies: 3
    Last Post: 06-13-2011, 11:28 PM
  4. Open and close web browser
    By ali_sakar in forum New To Java
    Replies: 2
    Last Post: 11-03-2009, 12:28 PM
  5. How to close an open JFrame window from a jsp page?
    By kasisaiganesh in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-27-2008, 06:29 PM

Posting Permissions

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