Results 1 to 7 of 7

Thread: Animating picbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2012
    Posts
    142

    Animating picbox

    Hey,
    I am trying to animate a picturebox with code something like this
    Code:
        Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
            player.Image = ImageAnimator.Animate(My.Resources.Playerwalk, New EventHandler(AddressOf Me.OnFrameChanged))
    
        End Sub
    
        Private Sub OnFrameChanged(ByVal o As Object, ByVal e As EventArgs)
            'Force a call to the Paint event handler. 
            Me.Invalidate()
        End Sub
    But it says imageAnimator.Animate expression does not produce a value.
    I cant seem to find an example anywhere. Is there a right way to do it or an alternative?
    I have a png of 256 wide and 80 high. each player frame is 32 wide and there are 8 different stages of movement. I want to draw the first 0-32 in a picturebox then the 32-64 and so on.
    I have no idea what to do. Please help me

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Animating picbox

    What is imageAnimator? Is it a custom class that you've created? Even so, animation in windows form applications are almost impossible. Not really impossible as more impractical. I would highly suggest using WPF or if you're insistant on using a windows form application, and using VS 2008 or higher, you could use XNA.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Animating picbox

    animation in windows form applications are almost impossible
    Say what? To start with PictureBox is fully compatible with animated .gif which is more than adequate for most purposes and there are plenty of example projects out there for throbbers, animated progress reporters and all sorts.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Animating picbox

    player.Image = ImageAnimator.Animate(My.Resources.Playerwalk, New EventHandler(AddressOf Me.OnFrameChanged))
    This is a direct call to a sub which returns no value so it's simply ...

    ImageAnimator.Animate(My.Resources.Playerwalk, New EventHandler(AddressOf Me.OnFrameChanged))
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Animating picbox

    Quote Originally Posted by dunfiddlin View Post
    Say what? To start with PictureBox is fully compatible with animated .gif which is more than adequate for most purposes and there are plenty of example projects out there for throbbers, animated progress reporters and all sorts.
    did you read the next sentence?
    Not really impossible as more impractical.
    I was simply suggesting that it's far easier to do animation in WPF or use XNA.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Animating picbox

    And I very much doubt that that's true either. ImageAnimator, by the way, is a native class under System.Drawing so MS certainly don't think that way.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Animating picbox

    What ever dude. No need to be like that. I'm taking the unsubscribe route.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

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