Comments (15)
Didf you take a look at the rajawali examples to see how its done?
https://github.com/MasDennis/RajawaliExamples
from rajawali.
Yes. I'm getting getWindowManager is undefined for wallpaper
and onTouchEvent(MotionEvent) is undefined
On May 29, 2012 12:43 AM, "Christoffer Green" <
[email protected]>
wrote:
Didf you take a look at the rajawali examples to see how its done?
https://github.com/MasDennis/RajawaliExamples
Reply to this email directly or view it on GitHub:
#40 (comment)
from rajawali.
do the examples compile for you?
from rajawali.
With wallpapers it works a bit different. There's no need to implement "OnTouchListener" etc. Just override the onTouchEvent(event) method in your class that extends RajawaliRenderer:
@Override
public void onTouchEvent(MotionEvent event) {
// ... do what ever you want ...
}
See also:
https://github.com/MasDennis/Rajawali/blob/master/src/rajawali/wallpaper/Wallpaper.java#L309
from rajawali.
What about getWindowManager being undefined? Is that also used differently
for wallpapers?
On May 29, 2012 5:38 AM, "Dennis Ippel" <
[email protected]>
wrote:
With wallpapers it works a bit different. There's no need to implement
"OnTouchListener" etc. Just override the onTouchEvent(event) method in your
class that extends RajawaliRenderer:
@Override
public void onTouchEvent(MotionEvent event) {
// ... do what ever you want ...
}
See also:https://github.com/MasDennis/Rajawali/blob/master/src/rajawali/wallpaper/Wallpaper.java#L309
Reply to this email directly or view it on GitHub:
#40 (comment)
from rajawali.
http://stackoverflow.com/questions/9052822/where-do-i-use-getwindowmanager-within-live-wallpaper
mContext = getBaseContext();
DisplayMetrics DisplayMetrics = new DisplayMetrics();
DisplayMetrics = mContext.getResources().getDisplayMetrics();
mScreenWidth = DisplayMetrics.widthPixels;
mSreenHeight = DisplayMetrics.heightPixels;
from rajawali.
mSurfaceView.onTouchListener(this); is getting the unreachable code error now. Everything else is fine.
If I use the eclipse recommended fix and remove it, the mContext lines of code get errors.
from rajawali.
Yeah, so in a wallpaper "this" is the Context. So it should be:
DisplayMetrics DisplayMetrics = new DisplayMetrics();
DisplayMetrics = getResources().getDisplayMetrics();
mScreenWidth = DisplayMetrics.widthPixels;
mSreenHeight = DisplayMetrics.heightPixels;
from rajawali.
mScreenWidth and mScreenHeight cannot be resolved to a variable
Would I eliminate
private Point mScreenSize;
What would be used for the screen height and width instead?
On May 30, 2012 2:45 AM, "Dennis Ippel" <
[email protected]>
wrote:
Yeah, so in a wallpaper "this" is the Context. So it should be:
DisplayMetrics DisplayMetrics = new DisplayMetrics();
DisplayMetrics = getResources().getDisplayMetrics();
mScreenWidth = DisplayMetrics.widthPixels;
mSreenHeight = DisplayMetrics.heightPixels;
Reply to this email directly or view it on GitHub:
#40 (comment)
from rajawali.
Yeah, you don't need all that. Like I said before, you only need this bit of code in your renderer class:
@Override
public void onTouchEvent(MotionEvent event) {
// ... do what ever you want ...
}
The rest is all taken care of by the Wallpaper class.
So to spell it out literally here's the whole class:
package com.mydomain.wallpapers.mywallpaper;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import rajawali.animation.Animation3D;
import rajawali.animation.RotateAnimation3D;
import rajawali.lights.ALight;
import rajawali.lights.DirectionalLight;
import rajawali.materials.DiffuseMaterial;
import rajawali.math.Number3D;
import rajawali.primitives.Cube;
import rajawali.renderer.RajawaliRenderer;
import rajawali.util.RajLog;
import android.content.Context;
import android.view.MotionEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
public class MyWallpaperRenderer extends RajawaliRenderer {
private Animation3D mAnim;
public MyWallpaperRenderer(Context context) {
super(context);
setFrameRate(60);
}
public void initScene() {
ALight light = new DirectionalLight();
light.setPower(1);
light.setPosition(0, 0, -5);
mCamera.setPosition(0, 0, -7);
Cube cube = new Cube(1);
DiffuseMaterial material = new DiffuseMaterial();
material.setUseColor(true);
cube.setMaterial(material);
cube.addLight(light);
cube.setColor(0xff00ff00);
addChild(cube);
Number3D axis = new Number3D(3, 1, 6);
axis.normalize();
mAnim = new RotateAnimation3D(axis, 360);
mAnim.setDuration(8000);
mAnim.setRepeatCount(Animation3D.INFINITE);
mAnim.setInterpolator(new AccelerateDecelerateInterpolator());
mAnim.setTransformable3D(cube);
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
super.onSurfaceCreated(gl, config);
mAnim.start();
}
public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep, float yOffsetStep, int xPixelOffset, int yPixelOffset) {
mCamera.setRotY(xOffset * 10);
}
// THIS IS WHAT YOU NEED!!!!!!!!!!!!!!!!!!!!!!!!
public void onTouchEvent(MotionEvent event) {
RajLog.i("TOUCH!!!!!!!!!");
}
public void onDrawFrame(GL10 glUnused) {
super.onDrawFrame(glUnused);
}
}
from rajawali.
I appreciate your help as well as others but here is where I am getting
errors. My renderer is fine.
package com.pspdemocenter.graffitilwp;
import rajawali.wallpaper.Wallpaper;
import rajawali.filters.TouchRippleFilter;
import android.content.Context;
import android.graphics.Point;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
import android.view.Gravity;
public class GraffitiLWP extends Wallpaper implements OnTouchListener {
private GraffitiLWPRenderer mRenderer;
private Point mScreenSize;
private SurfaceView mSurfaceView;
//private int mScreenWidth;
//private Context mContext;
//private int mSreenHeight;
public Engine onCreateEngine() {
mRenderer = new GraffitiLWPRenderer(this);
return new WallpaperEngine(this.getSharedPreferences(SHARED_PREFS_NAME,
Context.MODE_PRIVATE), getBaseContext(), mRenderer);
mSurfaceView.setOnTouchListener(this);
DisplayMetrics DisplayMetrics = new DisplayMetrics();
DisplayMetrics = getResources().getDisplayMetrics();
mScreenWidth = DisplayMetrics.widthPixels;
mSreenHeight = DisplayMetrics.heightPixels;
}
public void onTouchEvent(MotionEvent event) {
//if(event.getAction() == MotionEvent.ACTION_DOWN)
//{
mRenderer.setTouch(event.getX() / mScreenSize.x, 1.0f - (event.getY() /
mScreenSize.y));
//}
//super.onTouchEvent(event);
}
}
from rajawali.
Like I said before, remove the "implements OnTouchListener" from the class declaration.
To save me some time, just go over the code I posted carefully and compare it to your own class. It's all in the details ...
from rajawali.
Hi,
I have tried your code for wallpaper but it not called ontouchevent from GraffitiLWP . so how can i do it? thanks in advanced.
Thanks,
from rajawali.
I need some help
after writing this code in render class
@OverRide
public void onTouchEvent(MotionEvent event) {
// ... do what ever you want ...
}
where to write this line " mSurfaceView.setOnTouchListener(this); " in which method in render class?
from rajawali.
@flynnfernandes This issue is very old and Im not even certain it applies to your question. Please create a new issue with more context for what you are asking.
from rajawali.
Related Issues (20)
- jcenter repository has been depracated
- Seeking Luminance based desaturation
- Seeking Lighten and Darken Blend Modes
- Seeking point texture plugin
- improving SpriteSheetMaterialPlugin efficiency HOT 1
- Seeking Flexible Sprite Sheet Animation
- Seeking runtime adjustment of AlphaMask threshold
- Please restore AnimatedSpritesFragment to example app
- Stencil Buffer is not initializing corrrectly,
- Some `ScreenQuad` materials spew error messages at frame rate
- Objects starts to render with delay when camera if far from them HOT 1
- How to translate object with touch screen?
- anyway to implement ray in the library?
- Create Sphere with phiStart, phiLength, thetaStart, thetaLength HOT 1
- LoaderFBX.java:347 ArrayIndexOutOfBoundsException
- display obj model in AR
- Examples are broken
- When will the new version be released?
- load obj file fail,NumberFormatException: For input string: "nan"
- Caused by: org.rajawali3d.loader.ParsingException: Couldn't find texture ingrid HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rajawali.