maDrawimageRegion explanation from

2 posts / 0 new
Last post
markodjokovic
markodjokovic's picture
Offline
Mobile Wizard
Joined: 5 Oct 2010
Posts:
maDrawimageRegion explanation from

Hi,
Can anybody be kind to explain how is this scenario make (This is video from mosync)
http://www.youtube.com/watch?v=D2AI76H_oLU especially from time 0:30 where with touch event move object "boy with balone ", and in background is flow animation.

Now mine question is not how to do whole app only one of part of this,

I know this:
1. make transparent image,
2. create placeholder
3. use function maDrawImageRegion, and before make some rect, and m2point,
4. move is make by catching MAPoint2d, and calling fuction for each new value
pointerMoveEvent(MAPoint2d point)
{
x=point.x;
y=point.y
point2.x=x; //of corse point2 is defined before
point2.y=y;
maDrawImageRegion(RESURS, &rect, &point2,0);
//or something simular
}

now this perfect works if before
maDrawImageRegion(RESURS, &rect, &point2,0);
i add
maSetColor(0x000000);
maFillRect(0,0,240,320);
and always before call drawimage, i fill rect, to hide marks from before draw. If i not call fill rect it will have trace

in video there no have this problem animation behind is going smooth, and i assume that is also make in similar way something like time request, and for each period some counter is incresing.
Something like this:

runTimerEvent()
{
counter++;
Environment::getEnvironment().removeTimer(this);
draw ();
}
draw
{
point.x = 100;
point.y = counter;
maSetColor(0x000000);
maFillRect(0,0,240,320);
maDrawImageRegion(RESURS, &rect, &point,0);
Environment::getEnvironment().addTimer(this, 10, 1);
}

So this will handled behind movment .

So mine question will be how to draw image (first call) and to not call maFillRect, and also to image not leave some traceing.

This code that i type is experimental (maybe not work for sure), but that is idea, if anyone be kind to show me how to do last part.
Regards

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Patrick Broman
patrick's picture
Offline
Mobile Wizard
Joined: 17 Feb 2009
Posts:

Hi!
There are a couple of strategies you could use for doing animation. Here's some of them:

1) Always fill the entire screen by drawing a rect each frame, and then drawing your moving objects after that.
2) Same as above, but by blitting a screen-sized image each frame instead of doing an maFillRect()
3) Use "dirty rects", i.e. just replace the bit of the background that was overdrawn in the previous frame by doing a fillrect or maDrawImageRegion()

You could take a look at any number of examples for reference, including "advanced graphics" or "3d lines".