Back to project page SpaceRagdoll.
The source code is released under:
GNU General Public License
If you think the Android project SpaceRagdoll listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/******************************************************************************* * Copyright (C) 2015 Tuukka Ruhanen/* w w w.j a va 2 s.c om*/ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. *******************************************************************************/ package fi.karu.spaceragdoll; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.GL10; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.World; import fi.karu.spaceragdoll.controller.Controller; /** * This is the screen where the actual game runs in. * All events happening in the game are done with respect * to the call to the method render(), i.e. sending the * control events to the controller and updating the * parameters of the simulation (forces, speeds, etc.). */ public class GameScreen implements Screen, InputProcessor { private Space space; private SpaceRenderer renderer; private Controller controller; @Override public void render(float delta) { Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1); Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); renderer.render(); // box2d: render before update controller.update(); space.update(delta); } @Override public void resize(int width, int height) { renderer.resize(width, height); } @Override public void show() { space = new Space(); renderer = new SpaceRenderer(space); controller = new Controller(space); Gdx.input.setInputProcessor(this); } @Override public void hide() { // TODO Auto-generated method stub } @Override public void pause() { // TODO Auto-generated method stub } @Override public void resume() { // TODO Auto-generated method stub } @Override public void dispose() { // TODO Auto-generated method stub } @Override public boolean keyDown(int keycode) { // TODO Auto-generated method stub return false; } @Override public boolean keyUp(int keycode) { // TODO Auto-generated method stub return false; } @Override public boolean keyTyped(char character) { // TODO Auto-generated method stub return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { int y = Gdx.graphics.getHeight() - screenY; // origo to bottom left corner controller.touchDown(screenX, y, pointer); return true; } @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { // int y = Gdx.graphics.getHeight() - screenY; // origo to bottom left corner controller.touchUp(pointer); return true; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { int y = Gdx.graphics.getHeight() - screenY; // origo to bottom left corner controller.touchDragged(screenX, y, pointer); return true; } @Override public boolean mouseMoved(int screenX, int screenY) { // int y = Gdx.graphics.getHeight() - screenY; // origo to bottom left corner // TODO Auto-generated method stub return false; } @Override public boolean scrolled(int amount) { // TODO Auto-generated method stub return false; } }