Help for newbee

I have recently installed jme. I was trying to make a simple Pong like game. But I am not able to meake any improvement other than creating a window with four walls and a ball. I am not able to move the ball continuously in a particular direction either with a key or a mouse.

can someone help how to move the ball towards the walls?



leo

You could writing your own controller for the ball, but you can also just update it's coordinates.



Sphere ball = new Sphere(...);
rootNode.attachChild(ball);
ball.getLocalTranslation().x = 10;
// etc.



Try doing the flagrush tutorials on the wiki.

Thanks for the help. As I am using the BaseGame I can't use the rootNode. But the objects were attached to the Node. Now it works and the ball is moving. But the ball moves behind the walls if the ball is attached to the Node first. The ball moves behind the walls if i attach the ball to the Node last. the Z position of the ball does not match with the Z position of the walls. I do not know what is the problem?

here is the Source;

import com.jme.app.SimpleGame;

import com.jme.app.BaseGame;

import com.jme.bounding.BoundingBox;

import com.jme.image.Texture;

import com.jme.input.InputSystem;

import com.jme.input.KeyBindingManager;

import com.jme.input.KeyInput;

import com.jme.input.MouseInput;

import com.jme.math.Vector3f;

import com.jme.math.Quaternion;

import com.jme.renderer.Camera;

import com.jme.renderer.ColorRGBA;

import com.jme.scene.Node;

import com.jme.scene.shape.Box;

import com.jme.scene.shape.*;

import com.jme.scene.state.TextureState;

import com.jme.system.DisplaySystem;

import com.jme.system.JmeException;

import com.jme.util.TextureManager;

import com.jme.util.Timer;



public class Lesson2 extends BaseGame {

protected Timer timer;

private Camera cam;

private Node scene;

private TextureState ts;

private int width, height, depth, freq;

you have no zbufferstate set on your scene node…



why do you bother with using basegame instead of simplegame? better to use that first just to get the basic game up, and then switch to basegame(if you really need it) when you have gotten a bit more comfortable with jme…

I tried the simple game first. But the scene rotates when I move the mouse. I do not know how to disable the default mouse action. Please explain.



leo

Replace the InputHandler (I believe it's "input") with your own.