[SOLVED]How wallpaper scroll along with homescreen?

  ... the Live-Wallpaper Extension for AndEngine.

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby Kangee » Tue Oct 26, 2010 10:06 pm

I check my code and find no big mistakes. (i missed to explain that "mCamara" is a private field in the example and "Renderer" is an import from org.anddev.andengine.opengl.view.RenderSurfaceView.Renderer)

So It should work for you.

But maybe we do not talk about the same topic...

I mean this:

Image

Uploaded with ImageShack.us

The dolphin swims from one screen to the next screen.
Kangee
 
Posts: 9
Joined: Tue Aug 17, 2010 11:22 pm
Location: near Bremen, Germany

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby PowerApps » Sun Oct 31, 2010 2:56 am

Does the camera have to be bigger then the actually screen?
PowerApps
 
Posts: 23
Joined: Fri Aug 13, 2010 11:03 pm

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby Kangee » Tue Nov 02, 2010 9:20 am

I upload the Eclipse-Project as Zip-File. I think this is the answer of all questions ;-)
Attachments
dolphin_livewallpaper.zip
Use Eclipse->Import->Existing Project to import the project
(548.79 KiB) Downloaded 823 times
Kangee
 
Posts: 9
Joined: Tue Aug 17, 2010 11:22 pm
Location: near Bremen, Germany

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby PowerApps » Tue Nov 02, 2010 9:12 pm

Thanks, it's really a big help.
PowerApps
 
Posts: 23
Joined: Fri Aug 13, 2010 11:03 pm

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby knaikos » Sun Jan 09, 2011 11:15 pm

Hi!

I've been trying to make a Live Wallpaper with offset using andengine and finally I succeed (I must thank Kangee for the big help).

But now, I'm trying to add an extra funcionality: I have a moving sprite on the screen and I want to trigger an event when the sprite is touched.

My first thought was to use the OnTap Method (from the BaseLiveWallpaperService class):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. protected void onTap(final int pX, final int pY)
  3. {
  4.  
  5. }
  6.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Although it seems to be the easiest way, it doesn't work because the method is never called.
Then I tried to solve it using the TouchDragExample (included in the andengine example) :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. final Sprite face = new Sprite(centerX, centerY, this.mFaceTextureRegion) {
  3. @Override
  4. public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
  5. this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY() - this.getHeight() / 2);
  6. return true;
  7. }
  8.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


and then:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. scene.registerTouchArea(face);
  2. scene.setTouchAreaBindingEnabled(true);
  3.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


but it won't work neither (onAreaTouched is never called).

Is it possible that the implementation of onOffsetsChanged provided by Kangee interferes somehow with the other methods ?? I mean, maybe when pOffsetsChangedListener has been treated all the other listeners are discarded ?
I'm quite new to Android and Java, so please don't be very rude if I'm saying a nonsense :oops: .


Anyone has been able to manage offset and touch events in a Live Wallpaper made with andengine ?

Thanx!
knaikos
 
Posts: 4
Joined: Thu Dec 23, 2010 3:55 pm

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby hnim » Wed Apr 06, 2011 10:38 pm

@Kangee: i followed your tutorial, but i cant make my background scroll :( . This is how i set my bg:
scene.setBackground(new SpriteBackground(new Sprite(0, 0, mBackgroundTextureRegion)));
please help me. Thanks alot.
hnim
 
Posts: 7
Joined: Sun Feb 20, 2011 7:11 am

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby yeah00 » Thu May 26, 2011 10:32 am

knaikos wrote:Hi!
But now, I'm trying to add an extra funcionality: I have a moving sprite on the screen and I want to trigger an event when the sprite is touched.

My first thought was to use the OnTap Method (from the BaseLiveWallpaperService class):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. protected void onTap(final int pX, final int pY)
  3. {
  4.  
  5. }
  6.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


Although it seems to be the easiest way, it doesn't work because the method is never called.
Then I tried to solve it using the TouchDragExample (included in the andengine example) :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. final Sprite face = new Sprite(centerX, centerY, this.mFaceTextureRegion) {
  3. @Override
  4. public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
  5. this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY() - this.getHeight() / 2);
  6. return true;
  7. }
  8.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


and then:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. scene.registerTouchArea(face);
  2. scene.setTouchAreaBindingEnabled(true);
  3.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


but it won't work neither (onAreaTouched is never called).

Is it possible that the implementation of onOffsetsChanged provided by Kangee interferes somehow with the other methods ?? I mean, maybe when pOffsetsChangedListener has been treated all the other listeners are discarded ?
I'm quite new to Android and Java, so please don't be very rude if I'm saying a nonsense :oops: .


Anyone has been able to manage offset and touch events in a Live Wallpaper made with andengine ?

Thanx!



I have the same problem, IonAreaTouched is never called. One solution is to have all the sprites in an arraylist and then iterate through the list in the onTap method and check if the tap.x and tap.y equals the cordinates of the sprite. I have not tried it, but i have done this in an android app before(without andengine).

But really, doesnt the onAreaTouch work in live wallpaper?
yeah00
 
Posts: 15
Joined: Thu May 26, 2011 10:27 am

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby tencent » Fri May 27, 2011 4:08 am

Kangee wrote:I upload the Eclipse-Project as Zip-File. I think this is the answer of all questions ;-)


You are awesome for posting that file. One small change though as I believe your math is incorrect and this may help others. My LWP has objects spawn just outside the left and right sides of the screen then 'fly' across the screen and back off the the side opposite of their entry. So from left to right and right to left. My issue is that with your math currently when I replace your static sizes with proper screen sizes, I see the sprites spawning on the screen because the camera will either pan too far left or too far right. Now this may not be an issue for those of you that pick static camera dimensions regardless of device however I set my camera dimensions based on screen resolution from the Display class.

So I came up with this solution which is actually super straight forward.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. //cameraWidthHalf is just a pre calculated variable of camera.getWidth() * 0.5
  2. //cameraCenterY is just another optimization I put in that pre fetched the camera y center
  3. camera.setCenter(-xPixelOffset + cameraWidthHalf, cameraCenterY);
  4.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


I believe, and I have only tested on my vibrant and g1 with varying numbers of desktop screens. That this properly pans the camera.

Thank you again for posting your code!
tencent
 
Posts: 60
Joined: Sat May 21, 2011 1:29 am
Location: Florida

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby yeah00 » Fri May 27, 2011 2:40 pm

If anyone searching for the onTouch problem:

From another thread:
Nevermind I'm an idiot, I used the Live Wallpaper template, which overrides onTap, this prevented the touch events from flowing through, removed that override and all is good.


And thanks for the code!
yeah00
 
Posts: 15
Joined: Thu May 26, 2011 10:27 am

Re: [SOLVED]How wallpaper scroll along with homescreen?

Postby squeeb » Sun Jun 12, 2011 9:40 pm

i have downloaded the file and have been trying to get a background image to scroll.... how do you add a background image. sorry i am very new and trying to learn.

any help is appreciated :)
squeeb
 
Posts: 167
Joined: Mon May 16, 2011 1:24 am

PreviousNext

Return to Live-Wallpaper

Who is online

Users browsing this forum: No registered users and 4 guests