我有点问题。我想为我的AnimatedSprite对象制作控件。 (在Y范围移动) 不幸的是,当我按下我的精灵控制...... Eclipse给了我:
更糟糕的是,我不知道为什么以及如何解决这个问题?
有人能帮助我吗?
这是我的代码:
protected Scene onCreateScene() {
Scene scene = new Scene();
ParallaxLayer parallaxLayer = new ParallaxLayer(camera, true, 4000);
Sprite Srace_theme = new Sprite(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT, mrace_theme, this.getVertexBufferObjectManager());
parallaxLayer.setParallaxChangePerSecond(2);
parallaxLayer.setParallaxScrollFactor(1);
parallaxLayer.attachParallaxEntity(new ParallaxEntity(-110, Srace_theme, false, 1));
PhysicsWorld physics_world = new PhysicsWorld(new Vector2(0,0), false);
final FixtureDef PandusFixtureDef = PhysicsFactory.createFixtureDef(0, 0.0f, 0.0f);
final FixtureDef strzalka_gora_def = PhysicsFactory.createFixtureDef(0, 0.0f, 0.0f);
AnimatedSprite pandus_texture = new AnimatedSprite(10, 200, this.mgame_pandus, this.getVertexBufferObjectManager());
mgame_pandus_body = PhysicsFactory.createBoxBody(physics_world, pandus_texture, BodyType.KinematicBody, PandusFixtureDef);
physics_world.registerPhysicsConnector(new PhysicsConnector(pandus_texture, mgame_pandus_body, true, false));
velocity = Vector2Pool.obtain(2f, 0);
mgame_pandus_body.setLinearVelocity(velocity);// nadanie predkosci
Sprite s_strzalka_gora = new Sprite(730, 10, this.mstrzalka_gora, this.getVertexBufferObjectManager()){
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
velocity = Vector2Pool.obtain(2f, -2f);
mgame_pandus_body.setLinearVelocity(velocity);
Vector2Pool.recycle(velocity);
System.out.println("DOTKNIETY_gora");
return true;
}
};
body_strzalka_gora = PhysicsFactory.createBoxBody(physics_world, s_strzalka_gora, BodyType.KinematicBody, strzalka_gora_def);
s_strzalka_gora.setAlpha(0.5f);
scene.attachChild(parallaxLayer);
scene.registerUpdateHandler(physics_world);
scene.attachChild(pandus_texture);
scene.attachChild(s_strzalka_gora);
return scene;
}