I have a sprite image that i need to move horizontally on the screen. the image must move within the bounds of the screen from left to right and then from right to left. I have been able to render the image on the screen. But now i want to know which api and function would be used for the movement/animation?
Hello, I have a problem. Can`t build project for android after including s3eDialog.












Pos.x = Pos.x + 1;
?
this is exactly what i am trying to achieve but there are a few issues like:
1) how to redraw the image at the new position and clear the image at the previous one
2) how to use the timer for delay
3) is there some api that can do this or do i have manually write the code for manipulating the sprite
Hi,
You can move a sprite by drawing it at different coordinates on the screen. Basically it goes:
pos.x += 1; //moving your x to the right by 1, subtract to go the other way
Iw2DDrawImage(img, CIwSVec2(pos.x, pos.y)); //draw your image
As long as they are in your main while loop, it will change the position first and then redraw it at that new position every frame.
Have a look at this example, it moves "sprites".
http://www.madewithmarmalade.com/devnet/docs#/main/examplesandtutorials/...
Hi, i have the same issue raised above,http://www.madewithmarmalade.com/devnet/docs#/main/examplesandtutorials/... this link is not working,kindly provide me with some example of sprite movement.
Thankful to you.
Hi, i have the same issue raised above,http://www.madewithmarmalade.com/devnet/docs#/main/examplesandtutorials/... this link is not working,kindly provide me with some example of sprite movement.
Thankful to you.
hinaraza111,
Here is the full working code you need for sprite movement. Please have a look at our documentation and read about s3e and Iw2D to understand, what the code below does:
(Useful links:
http://www.madewithmarmalade.com/devnet/docs#/api/s3eapidocumentation.html
http://www.madewithmarmalade.com/devnet/docs#/api/iw2dapidocumentation.html
Here is the missing link from your post:
http://www.madewithmarmalade.com/devnet/docs#/main/native/examplesandtut...)
#include "s3e.h"
#include "iw2d.h"
int XPos = 0;
int main()
{
Iw2DInit();
CIw2DImage* img = Iw2DCreateImage("image.bmp");
while(!s3eDeviceCheckQuitRequest())
{
Iw2DSurfaceClear(0xffffffff);
Iw2DDrawImage(img, CIwSVec2(XPos++, 0), CIwSVec2(100, 100));
Iw2DSurfaceShow();
s3eDeviceYield();
}
delete img;
Iw2DTerminate();
return 0;
}
Good luck,
Chris