none
animation sprite small basic RRS feed

  • Question

  • hello,
    I'm trying to animate a sprite, and it seems to work, but there is an end in the top left and the one I want to animate, not erased. Yet it is well. Png, with the margin not to leave streaks.

    Maybe my code is not good:

     

      '________________________________________________________
    sprite[1]=ImageList.LoadImage("C:\____________BOMBE1.png")

    sprite[2]=ImageList.LoadImage("C:\____________BOMBE2.png")

    sprite[3]=ImageList.LoadImage("C:\____________BOMBE3.png")

    sprite[4]=ImageList.LoadImage("C:\____________BOMBE4.png")

    sprite[5]=ImageList.LoadImage("C:\____________BOMBE5.png")

    sprite[6]=ImageList.LoadImage("C:\____________BOMBE6.png")

    sprite[7]=ImageList.LoadImage("C:\____________BOMBE7.png")

    sprite[8]=ImageList.LoadImage("C:\____________BOMBE8.png")

    sprite[9]=ImageList.LoadImage("C:\____________BOMBE9.png")

    sprite[10]=ImageList.LoadImage("C:\____________BOMBE10.png")
    '____________________________________________________________________
    XBOMBE=200
    YBOMBE=200
     
    DEBUT :
    BOMBES = Shapes.AddImage(sprite[ib])
    Shapes.Move(BOMBES, XBOMBE, YBOMBE)
    '  BOMBES = Shapes.AddImage(sprite[ib])
    'Shapes.Move(BOMBES, XBOMBE, YBOMBE)
    ib=ib+1
    If ib>=10 Then
      ib=1
      endif
    XBOMBE=XBOMBE-0.01

    'Program.Delay(60)

    'ib=ib+1
    'If ib>=10 Then
    '  ib=1
    'endif

    Goto DEBUT

     

    does anyone see a solution?

     

    Thanks.

     


    absolu
    Wednesday, October 26, 2011 8:47 AM

Answers

All replies

  • Use

    Shape.Animate(shape, destX, destY, duration) instead

    Wednesday, October 26, 2011 2:09 PM
  • it doesn't work .
    absolu
    Thursday, October 27, 2011 8:30 AM
  • Yeah, I've heard about bugs from that method. You could also write your own code to animate:

    distanceX=300

    distanceY=250

    startX=50

    startY=20

    object=Shapes.AddEllipse(25,25)

    FrameRate=10

    For i = startY to startY+distanceY

        For j=startX to startX+distanceX

            Shapes.Move(object, i, j)

            Program.Delay(FrameRate)

        EndFor

    EndFor


    ~~AirWaves!!~~
    Thursday, October 27, 2011 8:55 AM
  • Try this. 

     XBOMBE=200
     YBOMBE=200
     
     For i= 1 To 10
       FD="C:\____________BOMBE"
       sprite[i]=ImageList.LoadImage(FD+i+".png") 
       BOMBES[i]= Shapes.AddImage(sprite[i])
       Shapes.HideShape(BOMBES[i])
     EndFor
     
     ib=1
    debut:
       Shapes.ShowShape(BOMBES[ib])
       Shapes.move(BOMBES[ib], XBOMBE, YBOMBE)
       ib=ib+1
       If ib>=10 Then
          ib=1
       endif
       XBOMBE=XBOMBE-0.1
    Goto DEBUT

    Thursday, October 27, 2011 9:13 AM
    Answerer
  • It's better, because it greatly simplifies the program, but it does not work properly yet.
    It looks like the sprite remains fixed in [i]. He moves well, but the animation is not yet clear.

    I also look on my side.

    thank you

    absolu
    Thursday, October 27, 2011 9:44 AM
  • Did you use Program.Delay(FRAMERATE)?
    ~~AirWaves!!~~
    Friday, October 28, 2011 3:40 AM
  • Yes, but may be it's not good, can you look please? :

     

    GraphicsWindow.Width = 1024
    GraphicsWindow.Height = 576
    graphicswindow.backgroundColor = "black"

    XBOMBE=200
    YBOMBE=200

    implantation()

    Sub implantation
    '________________________________________________________
    sprite[1]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE1.png")

    sprite[2]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE2.png")

    sprite[3]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE3.png")

    sprite[4]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE4.png")

    sprite[5]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE5.png")

    sprite[6]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE6.png")

    sprite[7]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE7.png")

    sprite[8]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE8.png")

    sprite[9]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE9.png")

    sprite[10]=ImageList.LoadImage("http://www.ctv-production.com/smallbasic/forum/BOMBE10.png")
    '____________________________________________________________________
    endsub


      DEBUT :
      anim()
      Program.Delay(25)
    Goto DEBUT




    Sub anim
    BOMBES = Shapes.AddImage(sprite[ib])
    Shapes.move(BOMBES, XBOMBE, YBOMBE)
    'Shape.Animate(shape, destX, destY, duration)
    '  BOMBES = Shapes.AddImage(sprite[ib])
    'Shapes.Move(BOMBES, XBOMBE, YBOMBE)
    ib=ib+1
    If ib>=10 Then
      ib=1
      endif
    XBOMBE=XBOMBE-0.1



    'ib=ib+1
    'If ib>=10 Then
    '  ib=1
    'endif
    EndSub

     

     

     


    absolu
    Friday, October 28, 2011 5:41 AM
  • Of course the animation is not clear; you are adding images one after another, then delaying the program for 25 milliseconds. Here is the order you want to use:

    1. Load Images before the game starts

    2. Add the images to the screen, but off to the side so the user does not see them.

    3. Then you animate them. But you can't do parts of a pixel in movement. I see you are trying to move the sprites a tenth of a pixel. That won't work. Just use something like 3 pixels; if you are able to get your code to move them fast enough, it won't matter 


    ~~AirWaves!!~~
    Friday, October 28, 2011 8:10 PM
  • can you show me an example of structure with my code, because what I did lots of tests but the results are always exotic ?

     

    Thank you?


    absolu
    Friday, October 28, 2011 10:41 PM
  • In fact, I think I have a problem of structure and syntax. Then I did a little better, but it does not work still. The sprite leaves streaks.

    Can you help me on the code or give me an example please?

     

     

    GraphicsWindow.Clear()
    GraphicsWindow.Width = 1024
    GraphicsWindow.Height = 576
    backColor = "black"

    XBOMBE=1000
    YBOMBE=200



    '________________________________________________________
    sprite[1]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE1.png")

    sprite[2]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE2.png")

    sprite[3]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE3.png")

    sprite[4]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE4.png")

    sprite[5]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE5.png")

    sprite[6]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE6.png")

    sprite[7]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE7.png")

    sprite[8]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE8.png")

    sprite[9]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE9.png")

    sprite[10]=Shapes.AddImage("http://www.ctv-production.com/smallbasic/forum/BOMBE10.png")
    '____________________________________________________________________



    ib=1



    DEBUT :

    Program.Delay(100)

    COMPILSPRITE()

    Shapes.move(sprite[ib], XBOMBE, YBOMBE+200)

    XBOMBE=XBOMBE-5
    YBOMBE=-50 * math.sin (10*XBOMBE)

    Goto DEBUT



    SUB COMPILSPRITE
      BOMBES = Shapes.AddImage(sprite[ib])
      ib=ib+1
      If ib>=10 Then
        ib=1
      endif
    endsub


    absolu
    Saturday, October 29, 2011 9:10 AM
  •  Try this.

     GraphicsWindow.Clear()
     GraphicsWindow.Width = 1024
     GraphicsWindow.Height = 576
     backColor = "black"
     
     XBOMBE=1000
     YBOMBE=200
     BMB="http://www.ctv-production.com/smallbasic/forum/BOMBE"
     
     For i=1 to 10
         sprite[i]=Shapes.AddImage(BMB+i+".png")
         Shapes.HideShape(sprite[i])   ' This is the point
     endfor

    ib=1
    DEBUT :
     Program.Delay(40)
     COMPILSPRITE()
     Shapes.move(sprite[ib], XBOMBE, YBOMBE+200)
     XBOMBE=XBOMBE-5
     If XBOMBE<-50 then
        XBOMBE=1000
     endif
     YBOMBE=-50 * math.sin (10*XBOMBE)
    Goto DEBUT
     
    SUB COMPILSPRITE
      Shapes.ShowShape(sprite[ib]) ' add this
       ib=ib+1
       If ib>=10 Then
         ib=1
       endif
     endsub


    Monday, October 31, 2011 1:57 AM
    Answerer
  • Yes, this time it's ok. I just changed a line.

    GraphicsWindow.Clear()
    GraphicsWindow.Width = 1024
    GraphicsWindow.Height = 576
    backColor = "black"

    XBOMBE=1100
    YBOMBE=200
    BMB="http://www.ctv-production.com/smallbasic/forum/BOMBE"

    For i=1 to 10
      sprite[i]=Shapes.AddImage(BMB+i+".png")
      Shapes.HideShape(sprite[i])   ' This is the point
    endfor

    ib=1

    DEBUT :
    Program.Delay(100)
    COMPILSPRITE()


    Goto DEBUT

    SUB COMPILSPRITE
      Shapes.move(sprite[ib], XBOMBE, YBOMBE+200)
      Shapes.ShowShape(sprite[ib]) ' add this
      XBOMBE=XBOMBE-5
    If XBOMBE<-50 then
      XBOMBE=1000
      endif
      YBOMBE=-50 * math.sin (10*XBOMBE)
      ib=ib+1
      If ib>=10 Then
        ib=1
      endif
    endsub

     

    Now, I want to remove this delay effect in the movement of sprite. One gets the impression that there is a drag, but I'd rather you see the bomb toutner on itself alone and in sinusoidal motion.

    I thought it was from the action for i. ....., etc. ... but I have no other idea?

    For if I want a character to move and the player with the keyboard or to the right or left with a feeling of movement and leg action, do not see this drag.

    Have you any idea ? 


    absolu
    Monday, October 31, 2011 3:18 AM
  • I found the solution ^ ^
    I mixed the brush ^ ^ (French speaking)
    This has to adapt, really depending on each program.

    Many thanks

    absolu
    Monday, October 31, 2011 3:21 AM
  • For the effect of drag, I still do not see how Eiter.

    Would have the sprites to disappear progressively. But how?

     

    GMS983

     

    If you have an idea, I'm interested.

    Thank you.


    absolu
    Wednesday, November 9, 2011 9:34 PM
  • Do you want to do this?

    GMS983-0

     

    Thursday, November 10, 2011 2:37 AM
    Answerer
  • The effect of opacity is nice, but that's not it.
    I wish there quune single sprite image that turns on itself (the principle of decomposition of 10 animated sprites) and moves.
    Hence it is like a caterpillar, or a kind of drag effect.

    S has at some point I want to have a character who moves in walking, with a keyboard event, I would not have this effect. It will be the character who walks alone, sprite after sprite.

    you know what I mean?

    absolu
    Thursday, November 10, 2011 6:47 AM
  • You'd better write an image like "detection collision sprite" thread.

    It wiil be helpful for me.

    Thursday, November 10, 2011 7:27 AM
    Answerer
  • This is a video link of an animation after effects :

     

    http://vimeo.com/31897822


    absolu
    Thursday, November 10, 2011 11:28 AM
  • You get to see the video ?

    absolu
    Friday, November 11, 2011 6:24 AM
  • Doy you want to make program runs like the video?(vimeo.com/31897822)

    If so, I'll try .


    Friday, November 11, 2011 6:34 AM
    Answerer
  • Yes, it is this style of animation, as in the video.

    Thank you for your advice!

    absolu
    Friday, November 11, 2011 7:24 AM
  • SQV324    

    BOMBE moves on sin wave.

    Friday, November 11, 2011 7:54 AM
    Answerer
  • Super!

    I will analyze the program!

    Thank you

    absolu
    • Marked as answer by absolu Saturday, November 12, 2011 9:34 PM
    Friday, November 11, 2011 8:12 AM