[Update] ParallaxLayer

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

Re: [Update] ParallaxLayer

Postby princetontiger » Fri Feb 14, 2014 7:57 am

The "WideSprite" example works!!

However, onOffsetChanged does not work on the Samsung TouchWiz interface... Anyone have any help on this?
Image
princetontiger
 
Posts: 64
Joined: Tue Jun 14, 2011 1:37 pm

Re: [Update] ParallaxLayer

Postby princetontiger » Sat Feb 15, 2014 5:44 pm

Thank you!!

I have solved your other issue.

Remember where you instantiate the animatedsprite parallax layer?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.      
  2.   parallaxLayer.attachParallaxEntity(new ParallaxEntity(-4, yourSprite, false, 10));
  3.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


see how I placed 10? That gives the entity equal spacing.

danilo wrote:Oh, guys, I am so happy I can give a contribution (even though it is small) to the forum.

I had that problem with AnimatedSprites (they were not updated) in the ParallaxLayer and I could fix it updating them in the onManagedUpdate method call.

Here it goes my modified method:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.         protected void onManagedUpdate(float pSecondsElapsed) {
  3.  
  4.                 final float cameraCenterPos = (mParallaxOnAxisX) ? this.mCamera
  5.                                 .getCenterX() : this.mCamera.getCenterY();
  6.  
  7.                 if (mIsScrollable && mCameraPreviousPos != cameraCenterPos) {
  8.                         mCameraOffsetPos = mCameraPreviousPos - cameraCenterPos;
  9.                         mCameraPreviousPos = cameraCenterPos;
  10.  
  11.                         this.mParallaxScrollValue += mCameraOffsetPos
  12.                                         * this.mParallaxScrollFactor;
  13.                         mCameraOffsetPos = 0;
  14.                 }
  15.                
  16.                 // trying to update the AnimatedSprites
  17.                 for (ParallaxEntity entity: mParallaxEntities) {
  18.                         if (entity.mAreaShape instanceof AnimatedSprite) {
  19.                                 ((AnimatedSprite) entity.mAreaShape).onUpdate(pSecondsElapsed);
  20.                         }
  21.                 }
  22.  
  23.                 this.mParallaxValue += this.mParallaxChangePerSecond * pSecondsElapsed;
  24.                 super.onManagedUpdate(pSecondsElapsed);
  25.         }
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


The lines 16 till 21 were added for me, where I check whether the entities are AnimatedSprite and call the update method for their draw.


Now I still have the problem that they are drawn many times after the first occurrence.
Image
princetontiger
 
Posts: 64
Joined: Tue Jun 14, 2011 1:37 pm

Re: [Update] ParallaxLayer

Postby wonson » Tue Nov 18, 2014 9:35 am

I have problem that it would not repeat to negative direction, and i found there is a one pixel overlapping at the edge of repeat.
wonson
 
Posts: 3
Joined: Thu Oct 30, 2014 4:42 am

Re: [Update] ParallaxLayer

Postby Hanzo » Fri Dec 05, 2014 12:04 pm

Hi guys

I'm new on AndEngine (achor center) and I'm learning about dynamic backgrounds with Parallax.

I've readed the original Jaym post and I was wondering how can help me Parallalayer.

I've trying to develop a simple game wich have a road whose auto-scroll is vertical. I need that if the character crashes into road lateral limit a counter increases.

How can I use Paralaxlayer with autoscrollbackground?

How can I create a vertical autoscroll instead of horizontal?

This is a bit of my code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.         protected void onCreateResources() {
  3.  
  4. (.....)
  5. this.mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(this.getTextureManager(), 2000, 2000);
  6. this.mParallaxLayerFront = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this, "escaled.jpg", 400, 300);
  7. this.mAutoParallaxBackgroundTexture.load();
  8.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.         protected Scene onCreateScene() {
  3.                 this.mEngine.registerUpdateHandler(new FPSLogger());
  4. sceneEjemplo = new Scene();                    
  5.                
  6. final AutoParallaxBackground autoParallaxBackground = new AutoParallaxBackground(0, 0, 0, 5);
  7. autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-10.0f, new Sprite(this.mParallaxLayerFront.getWidth() / 2 ,this.mParallaxLayerFront.getHeight() / 2, this.mParallaxLayerFront, getVertexBufferObjectManager())));
  8. sceneEjemplo.setBackground(autoParallaxBackground);
  9.  
  10. (.....)
  11.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


Thanks to all
Hanzo
 
Posts: 12
Joined: Fri Dec 05, 2014 11:47 am

Re: [Update] ParallaxLayer

Postby Foxy79 » Wed Sep 02, 2015 12:30 pm

Hi,

I want to use the ParallayLayer class, but my Player moves on the x and y axes.
The x axe should scroll slower as the player, and the y should allways be in the middle of the camera.
The paralax x axis works very well, but how can I make the paralax y-axe allways be in the middle of the camera?
Image
Foxy79
 
Posts: 4
Joined: Sat Dec 13, 2014 3:48 pm

Previous

Return to Features

Who is online

Users browsing this forum: No registered users and 9 guests