Tiling Sprite in Android

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Tiling Sprite in Android



I have these particles and I would like it to scroll down infinitely. What I mean is when whatever is drawn out of the screen when the particles scroll down, it goes back up and scrolls down from there again.
enter image description here



Is this possible in android java? Someone please help.





post some of your code
– Munkhdelger Tumenbayar
Aug 13 at 1:07




1 Answer
1



Here is a simplified explanation of how you can do it.


//Load the image containing the background image
Bitmap imgSrc = BitmapFactory.decodeResource(this, R.drawable.background_image);

//Crop it
Bitmap croppedImg = BitmapBitmap.createBitmap(imgSrc, 0, y, imgSrc.getWidth(), cropHeight);



This code portion will crop your image into a smaller part and store the cropped image in the variable croppedImage. To better understand how the cropping occurs, check here. The variables y and cropHeight are, respectively, the ordinate of the point from which you want to start the cropping and the height of the cropped image that is being created.



To implement this the way you want, you have to create a "time loop" (this might help you creating one), that is, a structure that permits you to execute a block of code every X seconds, milliseconds, etc. On every loop, you will increment the variable y and draw the background. Be careful thought, for y must not go out of the background image's bound. Also make sure that the background image isn't too big, otherwise you will have memory problems (that you can solve by scaling the image when loading it).





I believe I have. I tried to make the explanation as succinct as possible (since my point here is to make you understand the process, not to make it for you), which may have created some confusion in my writing. However, this doesn't give you the right to be rude. I was only trying to help and used my time for that. (this is an answer for a deleted comment from "Troll PC").
– Talendar
Aug 14 at 1:12







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered