Hi all,
in a GameView I move a worm across the screen. The worm is composed from a bounce of bitmapsdata (circles like the smiley sprite).
To move each element of the worm, I use a similar code like this (in a loop). The elements are types stored in a List
element.img.DestRect.Left = element.x - boxSize
element.img.DestRect.Right = element.x + boxSize
element.img.DestRect.Top = element.y - boxSize
element.img.DestRect.Bottom = element.y + boxSize
At the end I have:
gv.Invalidate
The questions:
- what should I do in order to add new worm elements ? I guess I have to:
---- add the element (bitmapdata) to the List
---- set the coordinates left and top accordingly
---- add the new bitmapdata to the gameview as done at the beginning
Am I right ?
More questions:
- How I can hide/show an element, or better, a whole worm in this case ? If I delete the bitmap from
the gameview, then I can't show it anymore. I could set the DestRect left,right,top,and bottom to 0, but I wonder if there is another way to hide/show a sprite from a gameview.
- How to change on the fly the sprite ? For instance, instead of a worm made of smileys, I need a worm made of flowers.
Regards,
Sergio
in a GameView I move a worm across the screen. The worm is composed from a bounce of bitmapsdata (circles like the smiley sprite).
To move each element of the worm, I use a similar code like this (in a loop). The elements are types stored in a List
element.img.DestRect.Left = element.x - boxSize
element.img.DestRect.Right = element.x + boxSize
element.img.DestRect.Top = element.y - boxSize
element.img.DestRect.Bottom = element.y + boxSize
At the end I have:
gv.Invalidate
The questions:
- what should I do in order to add new worm elements ? I guess I have to:
---- add the element (bitmapdata) to the List
---- set the coordinates left and top accordingly
---- add the new bitmapdata to the gameview as done at the beginning
Am I right ?
More questions:
- How I can hide/show an element, or better, a whole worm in this case ? If I delete the bitmap from
the gameview, then I can't show it anymore. I could set the DestRect left,right,top,and bottom to 0, but I wonder if there is another way to hide/show a sprite from a gameview.
- How to change on the fly the sprite ? For instance, instead of a worm made of smileys, I need a worm made of flowers.
Regards,
Sergio