How would one implement the effect of a sprite disappearing on one side of the screen and appearing on the other using AndEngine? Like in Kid Icarus, seen here at around 1:22.
|
As we discussed in the comments, you don't want to draw two sprites. So we go to the shader level. I've updated this for using with the fragment shader. You just need to pass in the screen min and max.
If you haven't done anything with shaders yet, you can read up about them here. EDIT Thinking about this more, I have no idea if it will even work. I don't know if things get culled off screen before or after this. You should test it out! |
|||||||||||
|
|
Unfortunately I've never used AndEngine before so I can't give you a specific answer to your problem, but I've asked a similar question before for XNA and got a great answer out of it. Here's a link to it: How to create a 2D region where sprites are automatically wrapped? That approach which uses a few render targets is great when you want wrapping to happen to everything in your game world automatically. That's because wrapping is done for the entire screen at once, instead of having to handle them individually for each object. Also notice that the example in that link is a lot more complicated, with complete 4-way wrapping in every direction. But if on the other hand only your main character will be doing the wrapping, and especially since you only need horizontal wrapping, then it's probably a lot easier to just draw your character two times when needed on each side of the screen. For instance something like the following pseudocode:
Where |
|||
|
|
