[Feature] ScrollScene

  ... the case you feel the need for a new feature or want to submit one.

[Feature] ScrollScene

Postby korn3l » Mon Nov 26, 2012 6:52 pm

I needed a class similar to CCScrollLayer from cocos2d so I created my own. I extended scene because it's easier to work with touch events there and I choose to move the scene instead of the camera.

It comes with a "snapping" effect. You can add sprites, buttonSprites, text, rectangles(basically everything that implements IAreaShape). The code is documented so it will be easier for you to use it.

I couldn't make a video of it, but I found a video that shows how CCScrollLayer works, and you should obtain the same thing using this class.


You can find the class on my git - ScrollScene. And ,if you feel like it, contribute to make it better.

Here is an example with how you can use it https://github.com/korn3l/TestScrollScene. I also added a page indicator in the example, but I made that in a hurry and I don't know if it's the best solution. If anyone knows a better one I am open to suggestions.

I hope this helps someone.

You can get the test apk from -->here<-- to get a sense of what it can do.
Last edited by korn3l on Thu Nov 29, 2012 10:36 am, edited 2 times in total.
korn3l
 
Posts: 214
Joined: Thu Apr 12, 2012 4:20 pm
Location: Iasi, Romania

Re: [Feature] ScrollScene

Postby Mathew » Mon Nov 26, 2012 7:16 pm

Really cool share, useful feature, I remember how long it took me to make something similar at beginning :)
User avatar
Mathew
 
Posts: 1073
Joined: Sun Jul 31, 2011 2:49 pm
Location: Tarnów, Poland

Re: [Feature] ScrollScene

Postby shihab_returns » Tue Nov 27, 2012 12:53 pm

great....thanks for sharing... :)

But getting error
1.
:
in Package org.andengine.testscrollscene;

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files


2. IOnScrollScenePageListener cannot be resolved to a type...

can u check plz..
Last edited by shihab_returns on Tue Nov 27, 2012 1:01 pm, edited 1 time in total.
shihab_returns
 
Posts: 105
Joined: Tue Oct 16, 2012 8:48 am
Location: Dhaka

Re: [Feature] ScrollScene

Postby korn3l » Tue Nov 27, 2012 12:56 pm

shihab_returns wrote:great....thanks for sharing... :)
Does it use Gles1..?


Only GLES 2 is supported for the moment. I plan on porting it for GLES2 Anchor Center, but I don't think that I'll do it for the gles1 branch, sry.
korn3l
 
Posts: 214
Joined: Thu Apr 12, 2012 4:20 pm
Location: Iasi, Romania

Re: [Feature] ScrollScene

Postby alfiroj » Tue Nov 27, 2012 2:48 pm

Great tutorial yaar... :)
alfiroj
 
Posts: 3
Joined: Wed Oct 24, 2012 6:21 am

Re: [Feature] ScrollScene

Postby korn3l » Tue Nov 27, 2012 3:45 pm

shihab_returns wrote:great....thanks for sharing... :)

But getting error
1.
:
in Package org.andengine.testscrollscene;

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files


2. IOnScrollScenePageListener cannot be resolved to a type...

can u check plz..



Update to the latest version. I added a few things like IOnScrollScenePageListener.
If you want the test project to work you have to, either get the ScrollScene class and add it to your project or you can get my Andengine branch.
korn3l
 
Posts: 214
Joined: Thu Apr 12, 2012 4:20 pm
Location: Iasi, Romania

Re: [Feature] ScrollScene

Postby shihab_returns » Wed Nov 28, 2012 6:26 am

it works... :D

You save my 1000 hours.

Plz keep your creative works & build our beloved andengine ;)
shihab_returns
 
Posts: 105
Joined: Tue Oct 16, 2012 8:48 am
Location: Dhaka

Re: [Feature] ScrollScene

Postby Mathew » Wed Nov 28, 2012 10:58 pm

What if we want use this scrolling feature, without using backgrounds, in your example, there are rectangles with different colours which acts like pages, what if we want to have one single background and move only sprites?

What I mean exactly, is there possibility to use it to receive same effect like on the attached video.
User avatar
Mathew
 
Posts: 1073
Joined: Sun Jul 31, 2011 2:49 pm
Location: Tarnów, Poland

Re: [Feature] ScrollScene

Postby korn3l » Thu Nov 29, 2012 10:09 am

Mathew wrote:What if we want use this scrolling feature, without using backgrounds, in your example, there are rectangles with different colours which acts like pages, what if we want to have one single background and move only sprites?

What I mean exactly, is there possibility to use it to receive same effect like on the attached video.


Just set the rectangles alpha's to 0 then you will see only the sprites attached to the pages.
See my game Running Rico. I use ScrollScene for the chapter and level select scenes. The pages are transparent and you only see the sprites attached to them.

*UPDATE* See post below.
Last edited by korn3l on Thu Nov 29, 2012 10:32 am, edited 1 time in total.
korn3l
 
Posts: 214
Joined: Thu Apr 12, 2012 4:20 pm
Location: Iasi, Romania

Re: [Feature] ScrollScene

Postby korn3l » Thu Nov 29, 2012 10:31 am

I realized that the pages should not be resized when added. The ScrollScene has a pagesize, but the pages can be bigger or smaller than the pagesize. I updated the ScrollScene and the example so now if you don't want to see the page you can either set the size to 0, 0 or you can do it the old way and set the alpha to 0.
korn3l
 
Posts: 214
Joined: Thu Apr 12, 2012 4:20 pm
Location: Iasi, Romania

Next

Return to Features

Who is online

Users browsing this forum: No registered users and 7 guests