當前位置: 首頁>>代碼示例>>Java>>正文


Java MovementSystem類代碼示例

本文整理匯總了Java中com.badlogic.ashley.tests.systems.MovementSystem的典型用法代碼示例。如果您正苦於以下問題:Java MovementSystem類的具體用法?Java MovementSystem怎麽用?Java MovementSystem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MovementSystem類屬於com.badlogic.ashley.tests.systems包,在下文中一共展示了MovementSystem類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import com.badlogic.ashley.tests.systems.MovementSystem; //導入依賴的package包/類
@Override
public void create () {
	OrthographicCamera camera = new OrthographicCamera(640, 480);
	camera.position.set(320, 240, 0);
	camera.update();

	Texture crateTexture = new Texture("assets/crate.png");
	Texture coinTexture = new Texture("assets/coin.png");

	engine = new PooledEngine();
	engine.addSystem(new RenderSystem(camera));
	engine.addSystem(new MovementSystem());

	Entity crate = engine.createEntity();
	crate.add(new PositionComponent(50, 50));
	crate.add(new VisualComponent(new TextureRegion(crateTexture)));

	engine.addEntity(crate);

	TextureRegion coinRegion = new TextureRegion(coinTexture);

	for (int i = 0; i < 100; i++) {
		Entity coin = engine.createEntity();
		coin.add(new PositionComponent(MathUtils.random(640), MathUtils.random(480)));
		coin.add(new MovementComponent(10.0f, 10.0f));
		coin.add(new VisualComponent(coinRegion));
		engine.addEntity(coin);
	}
}
 
開發者ID:DevelopersGuild,項目名稱:Planetbase,代碼行數:30,代碼來源:RenderSystemTest.java

示例2: create

import com.badlogic.ashley.tests.systems.MovementSystem; //導入依賴的package包/類
@Override
public void create() {
    OrthographicCamera camera = new OrthographicCamera(640, 480);
    camera.position.set(320, 240, 0);
    camera.update();

    Texture crateTexture = new Texture("assets/crate.png");
    Texture coinTexture = new Texture("assets/coin.png");

    engine = new PooledEngine();
    engine.addSystem(new RenderSystem(camera));
    engine.addSystem(new MovementSystem());

    Entity crate = engine.createEntity();
    crate.add(new PositionComponent(50, 50));
    crate.add(new VisualComponent(new TextureRegion(crateTexture)));

    engine.addEntity(crate);

    TextureRegion coinRegion = new TextureRegion(coinTexture);

    for (int i = 0; i < 100; i++) {
        Entity coin = engine.createEntity();
        coin.add(new PositionComponent(MathUtils.random(640), MathUtils.random(480)));
        coin.add(new MovementComponent(10.0f, 10.0f));
        coin.add(new VisualComponent(coinRegion));
        engine.addEntity(coin);
    }
}
 
開發者ID:grum,項目名稱:Ashley,代碼行數:30,代碼來源:RenderSystemTest.java


注:本文中的com.badlogic.ashley.tests.systems.MovementSystem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。