当前位置: 首页>>代码示例>>Java>>正文


Java Entity类代码示例

本文整理汇总了Java中org.andengine.entity.Entity的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Entity类属于org.andengine.entity包,在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Scrollable

import org.andengine.entity.Entity; //导入依赖的package包/类
/**
 * New Scrollable with with the desired width and height.
 * The width and height must be specified because a Scrollable will be smaller than the size
 * needed for all of it's children
 * @param x the X coordinate of the scene to place this Scrollable
 * @param y the Y coordinate of the scene to place this Scrollable
 * @param w the width for this Scrollable
 * @param h the height for this Scrollable
 * @param scroll_lock what directions can be scrolled (default Scrollable.SCROLL_BOTH)
 */
public Scrollable(float x, float y, float w, float h, int scroll_lock) {
    super(x, y, w, h);
    this.scroll_lock = scroll_lock;
    this.scrollDetector = new SurfaceScrollDetector(this);

    this.contents = new Entity(w/2, h/2, 0, 0);
    this.childRect.set(0, 0, 0, 0);
    this.touchAreas = new ArrayList<ITouchArea>();

    super.attachChild(this.contents);

    this.scrollbar_color = new Color(0.0f, 0.0f, 0.0f, 0.25f);
    this.vertical_scrollbar = new Rectangle(this.getWidth()-(this.scrollbar_size /2)-2, this.getHeight()/2, scrollbar_size, this.getHeight(), PhoeniciaContext.vboManager);
    this.vertical_scrollbar.setColor(this.scrollbar_color);
    if (this.scroll_lock == SCROLL_HORIZONTAL) this.vertical_scrollbar.setVisible(false);
    this.scroll_y = 0;
    super.attachChild(this.vertical_scrollbar);

    this.horizontal_scrollbar = new Rectangle(this.getWidth()/2, (scrollbar_size/2)+2, this.getWidth(), scrollbar_size, PhoeniciaContext.vboManager);
    this.horizontal_scrollbar.setColor(this.scrollbar_color);
    if (this.scroll_lock == SCROLL_VERTICAL) this.horizontal_scrollbar.setVisible(false);
    this.scroll_x = 0;
    super.attachChild(this.horizontal_scrollbar);

}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:36,代码来源:Scrollable.java

示例2: onManagedDraw

import org.andengine.entity.Entity; //导入依赖的package包/类
@Override
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {
	this.mSpriteBatch.setIndex(0);

	final Particle<Entity>[] particles = this.mParticles;
	for (int i = this.mParticlesAlive - 1; i >= 0; i--) {
		final Entity entity = particles[i].getEntity();

		/* In order to support alpha changes of the sprites inside the spritebatch,
		 * we have to 'premultiply' the RGB channels of the sprite with its alpha channel. */
		final float alpha = entity.getAlpha();
		final float colorABGRPackedInt = ColorUtils.convertRGBAToABGRPackedFloat(entity.getRed() * alpha, entity.getGreen() * alpha, entity.getBlue() * alpha, alpha);

		this.mSpriteBatch.drawWithoutChecks(this.mTextureRegion, entity, colorABGRPackedInt);
	}
	this.mSpriteBatch.submit();

	this.mSpriteBatch.onDraw(pGLState, pCamera);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:20,代码来源:BatchedPseudoSpriteParticleSystem.java

示例3: onManagedDraw

import org.andengine.entity.Entity; //导入依赖的package包/类
@Override
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {
	this.mSpriteBatch.setIndex(0);

	final Particle<Entity>[] particles = this.mParticles;
	for(int i = this.mParticlesAlive - 1; i >= 0; i--) {
		final Entity entity = particles[i].getEntity();

		/* In order to support alpha changes of the sprites inside the spritebatch,
		 * we have to 'premultiply' the RGB channels of the sprite with its alpha channel. */
		final float alpha = entity.getAlpha();
		final float colorABGRPackedInt = ColorUtils.convertRGBAToABGRPackedFloat(entity.getRed() * alpha, entity.getGreen() * alpha, entity.getBlue() * alpha, alpha);

		this.mSpriteBatch.drawWithoutChecks(this.mTextureRegion, entity, this.mTextureRegion.getWidth(), this.mTextureRegion.getHeight(), colorABGRPackedInt);
	}
	this.mSpriteBatch.submit();

	this.mSpriteBatch.onDraw(pGLState, pCamera);
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:20,代码来源:BatchedPseudoSpriteParticleSystem.java

示例4: setGameScene

import org.andengine.entity.Entity; //导入依赖的package包/类
private void setGameScene() {
    gameScene = new Scene();
    gameScene.setOnAreaTouchTraversalFrontToBack();
    final IOnSceneTouchListener sceneTouchListener = currentGame.getOnSceneTouchListener();
    if (sceneTouchListener != null) {
        gameScene.setOnSceneTouchListener(sceneTouchListener);
    }
    loadPhysics(currentGame);

    for (int i = 0; i < LAYER_COUNT; i++) {
        final Entity layer = new Entity();
        layer.setZIndex(i);
        gameScene.attachChild(layer);
    }

    loadHUD(currentGame);
    loadScene(currentGame);
    mEngine.setScene(gameScene);
    MusicManager.pause();
    music.play();
}
 
开发者ID:PLNech,项目名称:BactMan-Adventures,代码行数:22,代码来源:AbstractGameActivity.java

示例5: ImageMatchGameHUD

import org.andengine.entity.Entity; //导入依赖的package包/类
public ImageMatchGameHUD(final PhoeniciaGame phoeniciaGame, final Level level, final GameTile tile) {
    super(phoeniciaGame, level, tile);
    this.setBackgroundEnabled(false);
    this.level = level;
    this.tile = tile;
    this.current_round = 0;
    this.random_word_list = new ArrayList<Word>(level.words);
    Collections.shuffle(this.random_word_list);

    Debug.d("ImageMatchGame level: " + level.name);
    Debug.d("ImageMatchGame words: " + level.words.size());

    if (this.random_word_list.size() < this.max_rounds) {
        this.max_rounds = this.random_word_list.size();
    }
    Debug.d("ImageMatchGame  rounds: "+this.max_rounds);

    if (this.random_word_list.size() < this.max_choices) {
        this.max_choices = this.random_word_list.size();
    }

    this.touchAreas = new ArrayList<Entity>();
    choiceWordFont = FontFactory.create(PhoeniciaContext.fontManager, PhoeniciaContext.textureManager, 256, 256, TextureOptions.BILINEAR, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 36, Color.BLUE_ARGB_PACKED_INT);
    choiceWordFont.load();

    this.cardPane = new Entity(WINDOW_WIDTH/2, 400, WINDOW_WIDTH, 400);
    this.content.attachChild(cardPane);

    this.resultsPane = new Entity(WINDOW_WIDTH/2, 100, WINDOW_WIDTH, 200);
    this.content.attachChild(this.resultsPane);
    this.winnings = new ArrayList<Word>();
    this.result_number = 0;
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:34,代码来源:ImageMatchGameHUD.java

示例6: next_round

import org.andengine.entity.Entity; //导入依赖的package包/类
private void next_round() {
    this.current_round++;
    this.cardPane.detachChildren();
    for (Entity toucharea : this.touchAreas) {
        this.unregisterTouchArea(toucharea);
    }
    this.touchAreas.clear();

    if (this.current_round < this.max_rounds) {
        this.show_round(this.current_round);
    } else {
        // TODO: Show winnings
        this.end_game();
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:16,代码来源:ImageMatchGameHUD.java

示例7: HUDManager

import org.andengine.entity.Entity; //导入依赖的package包/类
/**
 * Create a new instance for the given PhoeniciaGame
 * @param game game to attach HUDs to
 */
public HUDManager(final PhoeniciaGame game) {
    this.game = game;
    this.hudStack = new Stack<PhoeniciaHUD>();
    this.hudLayer = new Entity(GameActivity.CAMERA_WIDTH/2, GameActivity.CAMERA_HEIGHT/2, GameActivity.CAMERA_WIDTH, GameActivity.CAMERA_HEIGHT);
    this.attachChild(this.hudLayer);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:11,代码来源:HUDManager.java

示例8: NumberMatchGameHUD

import org.andengine.entity.Entity; //导入依赖的package包/类
public NumberMatchGameHUD(final PhoeniciaGame phoeniciaGame, final Level level, final GameTile tile) {
    super(phoeniciaGame, level, tile);
    this.setBackgroundEnabled(false);
    this.level = level;
    this.tile = tile;
    this.current_round = 0;
    this.max_number = phoeniciaGame.locale.levels.indexOf(level)/2;
    if (this.max_number > this.game.locale.numbers.size()) {
        this.max_number = this.game.locale.numbers.size(); // Maximum we have number images for
    } else if (this.max_number < 3) {
        this.max_number = 3; // Minimum needed to display 3 choices
    }
    this.random_number_list = this.game.locale.numbers.subList(0, this.max_number);
    Collections.shuffle(this.random_number_list);

    this.random_word_list = new ArrayList<Word>(level.words);
    Collections.shuffle(this.random_word_list);

    Debug.d("NumberMatchGame level: " + level.name);
    Debug.d("NumberMatchGame words: " + level.words.size());

    if (this.max_number < this.max_rounds) {
        this.max_rounds = this.max_number;
    }
    Debug.d("NumberMatchGame  rounds: "+this.max_rounds);


    this.touchAreas = new ArrayList<Entity>();

    this.cardPane = new Entity(WINDOW_WIDTH/2, 400, WINDOW_WIDTH, 400);
    this.content.attachChild(cardPane);

    this.resultsPane = new Entity(WINDOW_WIDTH/2, 100, WINDOW_WIDTH, 200);
    this.content.attachChild(this.resultsPane);
    this.winnings = new ArrayList<Word>();
    this.result_number = 0;
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:38,代码来源:NumberMatchGameHUD.java

示例9: next_round

import org.andengine.entity.Entity; //导入依赖的package包/类
private void next_round() {
    this.current_round++;
    this.cardPane.detachChildren();
    for (Entity toucharea : this.touchAreas) {
        this.unregisterTouchArea(toucharea);
    }
    this.touchAreas.clear();

    if (this.current_round < this.max_rounds) {
        this.show_round(this.current_round);
    } else {
        this.end_game();
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:15,代码来源:NumberMatchGameHUD.java

示例10: WordMatchGameHUD

import org.andengine.entity.Entity; //导入依赖的package包/类
public WordMatchGameHUD(final PhoeniciaGame phoeniciaGame, final Level level, final GameTile tile) {
        super(phoeniciaGame, level, tile);

        this.level = level;
        this.tile = tile;
        this.current_round = 0;
        this.random_word_list = new ArrayList<Word>(level.words);
        Collections.shuffle(this.random_word_list);

        if (this.random_word_list.size() < this.max_rounds) {
            this.max_rounds = this.random_word_list.size();
        }
        Debug.d("WordMatchGame rounds: "+this.max_rounds);

        if (this.random_word_list.size() < this.max_choices) {
            this.max_choices = this.random_word_list.size();
        }

        this.touchAreas = new ArrayList<Entity>();
        choiceWordFont = FontFactory.create(PhoeniciaContext.fontManager, PhoeniciaContext.textureManager, 256, 256, TextureOptions.BILINEAR, Typeface.create(Typeface.DEFAULT, Typeface.BOLD), 36, Color.BLUE_ARGB_PACKED_INT);
        choiceWordFont.load();

//        final float dialogWidth = 800;
//        final float dialogHeight = 600;
//        Rectangle whiteRect = new BorderRectangle(GameActivity.CAMERA_WIDTH / 2, GameActivity.CAMERA_HEIGHT / 2, dialogWidth, dialogHeight, PhoeniciaContext.vboManager);
//        whiteRect.setColor(Color.WHITE);
//        this.attachChild(whiteRect);

        this.cardPane = new Entity(WINDOW_WIDTH/2, 400, WINDOW_WIDTH, 400);
        this.content.attachChild(cardPane);

        this.resultsPane = new Entity(WINDOW_WIDTH/2, 100, WINDOW_WIDTH, 200);
        this.content.attachChild(this.resultsPane);
        this.winnings = new ArrayList<Word>();
        this.result_number = 0;
    }
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:37,代码来源:WordMatchGameHUD.java

示例11: createBackground

import org.andengine.entity.Entity; //导入依赖的package包/类
private void createBackground() {
	pb = new ParallaxBackground(0.75f, 0.83f, 0.95f);
	Entity clouds = new Rectangle(0, 0, 1000, 800, vbom);
	clouds.setAnchorCenter(0, 0);
	clouds.setAlpha(0f);
	clouds.attachChild(new Sprite(100, 500, res.cloudRegion, vbom));
	clouds.attachChild(new Sprite(300, 700, res.cloudRegion, vbom));
	
	clouds.attachChild(new Sprite(500, 600, res.cloudRegion, vbom));
	clouds.attachChild(new Sprite(800, 730, res.cloudRegion, vbom));
	
	ParallaxEntity pe = new ParallaxEntity(-0.2f, clouds);
	pb.attachParallaxEntity(pe);
	setBackground(pb);
}
 
开发者ID:sm4,项目名称:FlyingDandelion,代码行数:16,代码来源:GameScene.java

示例12: onShowScene

import org.andengine.entity.Entity; //导入依赖的package包/类
@Override
public void onShowScene() {
    // Choose the right sequence to show. Only 2 now, but there'll be 9 different ones later
    switch (GameManager.getSelectedCharacter()) {
    case GameManager.CHAR_SHO:
        sequenceEntity = new EndingSequenceShoEasy();
        break;
    case GameManager.CHAR_RYOKO:
        sequenceEntity = new EndingSequenceRyokoEasy();
        break;
    default:
        break;
    }
    this.attachChild((Entity)sequenceEntity);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:16,代码来源:EndingScene.java

示例13: onShowScene

import org.andengine.entity.Entity; //导入依赖的package包/类
@Override
public void onShowScene() {
    // Choose the right sequence to show. Only 2 now, but there'll be 9 different ones later
    switch (GameManager.getSelectedCharacter()) {
    case GameManager.CHAR_SHO:
        sequenceEntity = new Intro2SequenceShoEasy();
        break;
    case GameManager.CHAR_RYOKO:
        sequenceEntity = new Intro2SequenceRyokoEasy();
        break;
    default:
        break;
    }
    this.attachChild((Entity)sequenceEntity);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:16,代码来源:Intro2Scene.java

示例14: addWordToQueue

import org.andengine.entity.Entity; //导入依赖的package包/类
protected void addWordToQueue(final WordBuilder builder, final boolean animate) {
    float buildQueueStartX = this.whiteRect.getWidth()/2 - (32*maxQueueSize) + 32;
    float startX = buildQueueStartX + (64 * this.queueSpriteMap.size());
    final ITiledTextureRegion wordSpriteRegion = game.wordSprites.get(tile.word);
    final TiledSprite wordSprite = new TiledSprite(startX, this.whiteRect.getHeight()-48, wordSpriteRegion, PhoeniciaContext.vboManager);
    this.whiteRect.attachChild(wordSprite);
    queueSpriteMap.put(builder, wordSprite);
    final ClickDetector builderClickDetector = new ClickDetector(new ClickDetector.IClickDetectorListener() {
        @Override
        public void onClick(ClickDetector clickDetector, int i, float v, float v1) {
            if (builder.status.get() == Builder.COMPLETE) {
                collectWord(wordSprite, builder);
            }
        }
    });
    Entity clickArea = new Entity(wordSprite.getWidth()/2, wordSprite.getHeight()/2, wordSprite.getWidth(), wordSprite.getHeight()) {
        @Override
        public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            return builderClickDetector.onManagedTouchEvent(pSceneTouchEvent);
        }
    };
    queueTouchAreaMap.put(builder, clickArea);
    wordSprite.attachChild(clickArea);
    this.registerTouchArea(clickArea);
    if (animate) {
        wordSprite.registerEntityModifier(new MoveYModifier(0.5f, this.buildPane.getY(), this.whiteRect.getHeight()-48));
        wordSprite.registerEntityModifier(new MoveXModifier(0.5f, this.wordSprite.getX(), startX));
    }


    final Text builderProgress = new Text(startX, this.whiteRect.getHeight()-96, GameFonts.inventoryCount(), "", 5, PhoeniciaContext.vboManager);
    this.whiteRect.attachChild(builderProgress);

    queueProgressMap.put(builder, builderProgress);
    builder.addUpdateHandler(this.queueUpdateHandler);

    switch (builder.status.get()) {
        case Builder.SCHEDULED:
            this.queueUpdateHandler.onScheduled(builder);
            break;
        case Builder.BUILDING:
            this.queueUpdateHandler.onStarted(builder);
            break;
        case Builder.COMPLETE:
            this.queueUpdateHandler.onCompleted(builder);
            break;
        default:
            wordSprite.setCurrentTileIndex(3);
    }
    this.queueUpdateHandler.onProgressChanged(builder);

}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:53,代码来源:WordBuilderHUD.java

示例15: addBuildingWord

import org.andengine.entity.Entity; //导入依赖的package包/类
private void addBuildingWord(final WorkshopBuilder builder, boolean animate) {
    Debug.d("Preparing to display active builder for: "+this.builder.item_name.get());
    final Word buildWord = game.locale.word_map.get(this.builder.item_name.get());
    final ITiledTextureRegion wordSpriteRegion = game.wordSprites.get(buildWord);
    this.buildSprite = new TiledSprite(whiteRect.getWidth()/2, this.queuePane.getHeight()-48, wordSpriteRegion, PhoeniciaContext.vboManager);
    this.queuePane.attachChild(this.buildSprite);
    final ClickDetector builderClickDetector = new ClickDetector(new ClickDetector.IClickDetectorListener() {
        @Override
        public void onClick(ClickDetector clickDetector, int i, float v, float v1) {
            Debug.d("Activated block: " + builder.getId());
            if (builder.status.get() == Builder.COMPLETE) {
                game.playBlockSound(buildWord.sound);
                Inventory.getInstance().add(builder.item_name.get());
                builder.item_name.set("");
                builder.status.set(Builder.NONE);
                builder.save(PhoeniciaContext.context);
                buildSprite.registerEntityModifier(new ParallelEntityModifier(
                        new MoveYModifier(0.5f, buildSprite.getY(), buildSprite.getY() + 128),
                        new FadeOutModifier(0.5f)
                ));
                tryButton.setVisible(true);
                tile.setAttention(false);
            } else {
                game.playBlockSound(buildWord.sound);
            }
        }
    });
    Entity clickArea = new Entity(buildSprite.getX(), buildSprite.getY(), buildSprite.getWidth(), buildSprite.getHeight()) {
        @Override
        public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            return builderClickDetector.onManagedTouchEvent(pSceneTouchEvent);
        }
    };
    this.queuePane.attachChild(clickArea);
    this.registerTouchArea(clickArea);


    this.buildProgress = new Text(whiteRect.getWidth()/2, this.queuePane.getHeight()-90, GameFonts.inventoryCount(), "", 5, PhoeniciaContext.vboManager);
    this.queuePane.attachChild(buildProgress);

    builder.addUpdateHandler(this.buildUpdateHandler);

    switch (builder.status.get()) {
        case Builder.SCHEDULED:
            this.buildUpdateHandler.onScheduled(builder);
            break;
        case Builder.BUILDING:
            this.buildUpdateHandler.onStarted(builder);
            break;
        case Builder.COMPLETE:
            this.buildUpdateHandler.onCompleted(builder);
            break;
        default:
            buildSprite.setCurrentTileIndex(3);
    }
    this.buildUpdateHandler.onProgressChanged(builder);

    if (animate) {
        this.buildSprite.registerEntityModifier(
                new ScaleModifier(0.3f, 0.2f, 1.0f)
        );
    }
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:64,代码来源:WorkshopHUD.java


注:本文中的org.andengine.entity.Entity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。