How do you move a picture object around the screen after you have declared it? Maybe a picture isn't the right type of object for this?
For example, I have a logo that I want to move around the screen like a screensaver. I have tried to manipulate the x and y coordinates of that object, but it crashes my system.
D4D_DECLARE_STD_PICTURE(scrn_logo, 70, 50, &bmp_Logo);static void Screen_OnMain(){ D4D_PICTURE *pict; pict = D4D_GET_PICTURE(&scrn_logo); pict->scrPos.y += 1;}
This obviously isn't the correct way to do this. I cut out code in this example that deals with timing and bound checking; that is not the problem I'm having.
Solved! Go to Solution.
Hello Toe,
You have to declare the object in RAM:
For example:
D4D_DECLARE_STD_PICTURE_INRAM(mov_picture, BRD_POSX, BRD_POSY, &bmp_blue)
In any point of your program you can change coordinates and move the picture:
POSX=POSX+10; POSY=POSY+10; pPoint->x=POSX; pPoint->y=POSY; MovePicture((D4D_OBJECT*)&mov_picture, pPoint);
This is the MovePicture function, you have to 'erase' the previous position on the screen, as eGUI doesn't save any screen content.
void MovePicture(D4D_OBJECT* pPictObject, D4D_POINT* pPoint){ D4D_PICTURE* pPict = D4D_GET_PICTURE(pPictObject); D4D_SIZE size = { 64, 64 }; D4D_FillRect(&(pPict->scrPos), & size, D4D_COLOR_RGB(192, 192, 192)); pPict->scrPos = *pPoint; D4D_InvalidateObject(pPictObject, D4D_TRUE);}
You will have to work with a solid color in the background.
Best Regards,
Luis
Hello Toe,
You have to declare the object in RAM:
For example:
D4D_DECLARE_STD_PICTURE_INRAM(mov_picture, BRD_POSX, BRD_POSY, &bmp_blue)
In any point of your program you can change coordinates and move the picture:
POSX=POSX+10; POSY=POSY+10; pPoint->x=POSX; pPoint->y=POSY; MovePicture((D4D_OBJECT*)&mov_picture, pPoint);
This is the MovePicture function, you have to 'erase' the previous position on the screen, as eGUI doesn't save any screen content.
void MovePicture(D4D_OBJECT* pPictObject, D4D_POINT* pPoint){ D4D_PICTURE* pPict = D4D_GET_PICTURE(pPictObject); D4D_SIZE size = { 64, 64 }; D4D_FillRect(&(pPict->scrPos), & size, D4D_COLOR_RGB(192, 192, 192)); pPict->scrPos = *pPoint; D4D_InvalidateObject(pPictObject, D4D_TRUE);}
You will have to work with a solid color in the background.
Best Regards,
Luis
Hello, i´m in the same trouble. I´m trying to move a button in the screen, just moving it to another coordinate, but what it really happens is, the button that I declared INRAM just refresh on the screen, and do not moves.
I changed the MovePicture to MoveButton, redeclared all of the pointers and structures to work with D4D_BUTTON, but it did not work.
Can you help me?
Thank you, that's what I was looking for.