Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected Body body;
- public Creature(final float pX, final float pY, final ITextureRegion textureRegion, GameEngine i_Engine) {
- super(pX, pY, textureRegion);
- this.speed_multi = 1;
- this.flips = false;
- this.mEngine = i_Engine;
- this.fixDef = PhysicsFactory.createFixtureDef(0, 0, 0);
- this.body = PhysicsFactory.createBoxBody(this.mEngine.getPhy(), this, BodyType.DynamicBody, this.fixDef);
- this.body.setUserData(this);
- this.mEngine.getPhy().registerPhysicsConnector(new PhysicsConnector(this, body, true, true));
- }
- public void setVelocity(float vX, float vY) {
- Vector2 mVelocity = Vector2Pool.obtain(vX, vY);
- this.body.setLinearVelocity(mVelocity);
- Vector2Pool.recycle(mVelocity);
- }
- public void randomizeVelocity() {
- Random gen = new Random();
- float x = gen.nextInt(10)-5;
- float y = gen.nextInt(10)-5;
- Debug.d("Setting Velocity", "Val: " + x + " " + y);
- this.setVelocity(x, y);
- }
Add Comment
Please, Sign In to add comment