• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AutoWrap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: show_sorry

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
private void show_sorry() {
    Dialog sorry_dialog = new Dialog(400, 150, Dialog.Buttons.OK, PhoeniciaContext.vboManager, new Dialog.DialogListener() {
        @Override
        public void onDialogButtonClicked(Dialog dialog, Dialog.DialogButton dialogButton) {
            dialog.close();
            unregisterTouchArea(dialog);
            finish();
        }
    });
    String counts = String.format("%1$d/%2$d", this.winnings.size(), this.max_rounds);
    Text sorry_text = new Text(sorry_dialog.getWidth()/2, sorry_dialog.getHeight()-48, GameFonts.dialogText(), counts, counts.length(),  new TextOptions(AutoWrap.WORDS, sorry_dialog.getWidth()*0.8f, HorizontalAlign.CENTER), PhoeniciaContext.vboManager);
    sorry_text.setColor(Color.RED);
    sorry_dialog.attachChild(sorry_text);

    this.registerTouchArea(sorry_dialog);

    sorry_dialog.open(this);
    GameSounds.play(GameSounds.FAILED);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:20,代码来源:ImageMatchGameHUD.java


示例2: showPage

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
/**
 * Change the display to the specified IntroPage
 * @param page_index page to display
 */
private void showPage(int page_index) {
    Debug.d("Showing page: "+page_index);
    this.current_page = page_index;
    final String nextPage = level.intro.get(page_index).text;
    final TextOptions introTextOptions = new TextOptions(AutoWrap.WORDS, messageBox.getWidth()-64, HorizontalAlign.LEFT);
    final Text introPageText = new Text(messageBox.getWidth()/2 - 32, messageBox.getHeight()/2, GameFonts.introText(), nextPage, introTextOptions, PhoeniciaContext.vboManager);
    introPageText.setPosition(messageBox.getWidth() / 2, messageBox.getHeight() - (introPageText.getHeight() / 2));

    this.messageBox.setHeight(introPageText.getHeight() + 64);
    introPageText.setPosition(this.messageBox.getWidth() / 2 + 16, this.messageBox.getHeight() - (introPageText.getHeight() / 2));

    messageBox.detachChildren();
    messageBox.attachChild(introPageText);
    messageBox.attachChild(this.nextButton);

    game.playLevelSound(level.intro.get(page_index).sound, this);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:22,代码来源:LevelIntroHUD.java


示例3: splitLines

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
/**
 * Does not respect linebreaks!
 *
 * @param pFont
 * @param pText
 * @param pResult
 * @param pAutoWrapWidth
 * @return
 */
public static <L extends List<CharSequence>> L splitLines(final IFont pFont, final CharSequence pText, final L pResult, final AutoWrap pAutoWrap, final float pAutoWrapWidth) {
	/**
	 * TODO In order to respect already existing linebreaks, {@link #split(CharSequence, java.util.List)} could be leveraged and than the following methods could be called for each line.
	 */
	switch (pAutoWrap) {
		case LETTERS:
			return FontUtils.splitLinesByLetters(pFont, pText, pResult, pAutoWrapWidth);
		case WORDS:
			return FontUtils.splitLinesByWords(pFont, pText, pResult, pAutoWrapWidth);
		case CJK:
			return FontUtils.splitLinesByCJK(pFont, pText, pResult, pAutoWrapWidth);
		case NONE:
		default:
			throw new IllegalArgumentException("Unexpected " + AutoWrap.class.getSimpleName() + ": '" + pAutoWrap + "'.");
	}
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:26,代码来源:FontUtils.java


示例4: splitLines

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
/**
 * Does not respect linebreaks!
 * 
 * @param pFont
 * @param pText
 * @param pResult
 * @param pAutoWrapWidth
 * @return
 */
public static <L extends List<CharSequence>> L splitLines(final IFont pFont, final CharSequence pText, final L pResult, final AutoWrap pAutoWrap, final float pAutoWrapWidth) {
	/**
	 * TODO In order to respect already existing linebreaks, {@link FontUtils#split(CharSequence, List)} could be leveraged and than the following methods could be called for each line.
	 */
	switch(pAutoWrap) {
		case LETTERS:
			return FontUtils.splitLinesByLetters(pFont, pText, pResult, pAutoWrapWidth);
		case WORDS:
			return FontUtils.splitLinesByWords(pFont, pText, pResult, pAutoWrapWidth);
		case CJK:
			return FontUtils.splitLinesByCJK(pFont, pText, pResult, pAutoWrapWidth);
		case NONE:
		default:
			throw new IllegalArgumentException("Unexpected " + AutoWrap.class.getSimpleName() + ": '" + pAutoWrap + "'.");
	}
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:26,代码来源:FontUtils.java


示例5: splitLines

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
/**
 * Does not respect linebreaks!
 *
 * @param pFont
 * @param pText
 * @param pResult
 * @param pAutoWrapWidth
 * @return
 */
public static <L extends List<CharSequence>> L splitLines(final IFont pFont, final CharSequence pText, final L pResult, final AutoWrap pAutoWrap, final float pAutoWrapWidth) {
	/**
	 * TODO In order to respect already existing linebreaks, {@link #split(CharSequence, List)} could be leveraged and than the following methods could be called for each line.
	 */
	switch (pAutoWrap) {
		case LETTERS:
			return FontUtils.splitLinesByLetters(pFont, pText, pResult, pAutoWrapWidth);
		case WORDS:
			return FontUtils.splitLinesByWords(pFont, pText, pResult, pAutoWrapWidth);
		case CJK:
			return FontUtils.splitLinesByCJK(pFont, pText, pResult, pAutoWrapWidth);
		case NONE:
		default:
			throw new IllegalArgumentException("Unexpected " + AutoWrap.class.getSimpleName() + ": '" + pAutoWrap + "'.");
	}
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:26,代码来源:FontUtils.java


示例6: initTalk

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
public void initTalk(SparseArray<TiledSprite> faces, List<PlayerTalkDto> talks) {
	// 初期化
	this.talkIndex = 0;
	this.textMaxLength = 0;
	
	// 会話する顔を登録
	this.faces = faces;
	
	// 会話内容を登録
	this.talks = talks;
	
	// 設定された会話内容を元に最大テキストサイズで初期化してTextを用意する
	textMaxLength = getMaxLength(talks);
	talkText = new Text(16, 16, font, 
			getSizeToStr("-", textMaxLength), 
			new TextOptions(HorizontalAlign.LEFT), 
			baseScene.getBaseActivity().getVertexBufferObjectManager());
	talkText.setAutoWrap(AutoWrap.WORDS);
	nameText = new Text(16, 16, font, 
			getSizeToStr("-", textMaxLength), 
			new TextOptions(HorizontalAlign.LEFT), 
			baseScene.getBaseActivity().getVertexBufferObjectManager());
	nameText.setColor(Color.GREEN);
	
	nextTalk();
}
 
开发者ID:kyokomi,项目名称:AndEngineSRPGQuest,代码行数:27,代码来源:TalkLayer.java


示例7: showMessage

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
public void showMessage(Message message, MessageBox position, final boolean showNextButton, final MediaPlayer.OnCompletionListener listener) {
    String messageText = message.text;
    String messageSound = message.sound;

    this.messageBox.detachChildren();
    this.nextButton.setVisible(false);
    this.messageBox.attachChild(this.nextButton);

    this.positionMessageBox(position);
    this.displayText = new Text(this.messageBox.getWidth()/2+16, this.messageBox.getHeight()/2, GameFonts.introText(), messageText, messageText.length(), new TextOptions(HorizontalAlign.LEFT), PhoeniciaContext.vboManager);
    this.displayText.setAutoWrapWidth(this.messageBox.getWidth() - 32);
    this.displayText.setAutoWrap(AutoWrap.WORDS);

    this.messageBox.setHeight(this.displayText.getHeight() + 64);
    this.displayText.setPosition(this.messageBox.getWidth() / 2 + 16, this.messageBox.getHeight() - (this.displayText.getHeight() / 2));

    this.messageBox.attachChild(this.displayText);
    if (messageSound != null && messageSound.length() > 0) {
        Debug.d("Playing tour message sound: '" + messageSound + "'");
        this.messagePlaying = true;
        this.game.playLevelSound(messageSound, new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                messagePlaying = false;
                if (listener != null) {
                    listener.onCompletion(mp);
                }
                if (showNextButton) {
                    nextButton.setVisible(true);
                }
            }
        });
    }


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


示例8: show_reward

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
private void show_reward() {
    Collections.shuffle(this.winnings);
    final Word reward_word = this.winnings.get(0);
    final int reward_coins = Math.round(reward_word.sell * this.tile.game.reward);
    final int reward_points = Math.round(reward_word.points * this.tile.game.reward);

    final Dialog reward_dialog = new Dialog(400, 300, Dialog.Buttons.OK, PhoeniciaContext.vboManager, new Dialog.DialogListener() {
        @Override
        public void onDialogButtonClicked(Dialog dialog, Dialog.DialogButton dialogButton) {
            finish();
            Inventory.getInstance().add(reward_word.name, 1, false);
            Bank.getInstance().credit(reward_coins);
            game.session.addExperience(reward_points);
            GameSounds.play(GameSounds.COLLECT);
            dialog.close();
            unregisterTouchArea(dialog);
        }
    });

    String counts = String.format("%1$d/%2$d", this.winnings.size(), this.max_rounds);
    Text reward_text = new Text(reward_dialog.getWidth()/2, reward_dialog.getHeight()-24, GameFonts.dialogText(), counts, counts.length(),  new TextOptions(AutoWrap.WORDS, reward_dialog.getWidth()*0.8f, HorizontalAlign.CENTER), PhoeniciaContext.vboManager);
    reward_text.setColor(Color.GREEN);
    reward_dialog.attachChild(reward_text);

    ITiledTextureRegion sprite_region = this.game.wordSprites.get(reward_word);
    Sprite reward_sprite = new Sprite(reward_dialog.getWidth()/2, reward_dialog.getHeight() - 100, sprite_region.getTextureRegion(1), PhoeniciaContext.vboManager);
    reward_dialog.attachChild(reward_sprite);

    ITextureRegion coinRegion = GameUI.getInstance().getCoinsIcon();
    Sprite coinIcon = new Sprite(reward_dialog.getWidth()/2 - 32, 112, coinRegion, PhoeniciaContext.vboManager);
    coinIcon.setScale(0.5f);
    reward_dialog.attachChild(coinIcon);

    Text iconDisplay = new Text(reward_dialog.getWidth()/2 + 32, 112, GameFonts.dialogText(), String.valueOf(reward_coins), 10, new TextOptions(HorizontalAlign.LEFT), PhoeniciaContext.vboManager);
    reward_dialog.attachChild(iconDisplay);

    this.registerTouchArea(reward_dialog);
    reward_dialog.open(this);
    GameSounds.play(GameSounds.COMPLETE);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:41,代码来源:ImageMatchGameHUD.java


示例9: addRequestToQueue

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
private void addRequestToQueue(final MarketRequest request, final boolean animate) {
    float startX = (this.requestsPane.getWidth()) - (this.columns * 192) + 96;
    float startY = this.requestsPane.getHeight() - 128;

    float column = this.requestPerson.size() % 2;
    float row = (int)(this.requestPerson.size()/2);
    final Person currentPerson = game.locale.person_map.get(request.person_name.get());
    if (currentPerson == null) {
        Debug.d("Market Request without person!");
        return;
    }
    Debug.d("Adding Market request: " + currentPerson.name);
    final ITextureRegion personRegion = game.personTiles.get(currentPerson);

    final ButtonSprite block = new ButtonSprite(startX + (192 * column), startY - (288 * row), personRegion, PhoeniciaContext.vboManager);
    block.setOnClickListener(new ButtonSprite.OnClickListener() {
        @Override
        public void onClick(ButtonSprite buttonSprite, float v, float v2) {
            Debug.d("Request from " + currentPerson.name + " clicked");
            populateRequestItems(request);
        }
    });
    requestsPane.registerTouchArea(block);
    requestsPane.attachChild(block);
    this.requestPerson.put(request, block);

    Text personName = new Text(block.getWidth()/2, -16, GameFonts.dialogText(), currentPerson.name, currentPerson.name.length(),  new TextOptions(AutoWrap.WORDS, 192, HorizontalAlign.CENTER), PhoeniciaContext.vboManager);
    block.attachChild(personName);
    this.requestName.put(request, personName);

    this.requestQueue.add(request);
    if (animate) {
        block.registerEntityModifier(new MoveYModifier(0.5f, -(block.getHeight()/2), startY - (288 * row)));
    }

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


示例10: generatePowerUp

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
/**
 * Generate a power up that can be collected by shooting it.
 * @param x the x pos
 * @param y the y pos
 * @return the generated power up
 */
public Entity generatePowerUp(float centerX, float centerY, PowerUpTypeEnum type) {
	final Sprite sPowerUp = new Sprite(0, 0, spriteLoader.getPowerUpTextureRegion(), this.vertextBufferObjectManager);
	sPowerUp.setZIndex(9);
	SpriteUtil.setCenter(sPowerUp, centerX, centerY);
	Entity powerUp = this.em.createEntity();
	this.em.addComponentToEntity(new SpriteComponent(sPowerUp, false), powerUp);
	
	Text puText = new Text(0, 0, spriteLoader.getPowerUpFont(), "azertyuiop azertyuiop azertyuiop", new TextOptions(AutoWrap.WORDS, 74, HorizontalAlign.CENTER), this.vertextBufferObjectManager);
	puText.setPosition(43 - puText.getWidth()/2f, 43 - puText.getHeight()/2f);

	sPowerUp.attachChild(puText);
	this.em.addComponentToEntity(new PowerUpComponent(type, 4, puText), powerUp);
	return powerUp;
}
 
开发者ID:Callilf,项目名称:RotatingSentries,代码行数:21,代码来源:EntityFactory.java


示例11: SessionSprite

import org.andengine.entity.text.AutoWrap; //导入依赖的package包/类
public SessionSprite(float px, float py, GameSession session, VertexBufferObjectManager vbo) {
    super(px, py, PhoeniciaGame.PERSON_TILE_WIDTH, PhoeniciaGame.PERSON_TILE_HEIGHT+32);
    Debug.d("Adding SessionSprite as "+px+","+py);
    this.session = session;
    if (session.session_name.get() == null) {
        Debug.d("Session has no name, setting it to Player " + (sessionSprites.size() + 1));
        session.session_name.set("Player "+(sessionSprites.size()+1));
        //session.session_name.set("Mchezaji"+(sessionSprites.size()+1));
        session.save(PhoeniciaContext.context);
    }
    Debug.i("Adding Game session: " + session.session_name.get() + " in " + session.locale_pack.get());
    LocaleLoader localeLoader = new LocaleLoader();
    Locale session_locale;
    try {
        session_locale = localeLoader.load(PhoeniciaContext.assetManager.open(session.locale_pack.get()));
        Person currentPerson = session_locale.person_map.get(session.person_name.get());
        if (currentPerson == null) {
            Debug.w("Game Session without person!");
            // TODO: use an "unknown user" image instead
            int person_index = sessionSprites.size() % session_locale.people.size();
            currentPerson = session_locale.people.get(person_index);
            session.person_name.set(currentPerson.name);
            session.save(PhoeniciaContext.context);
        }
        AssetBitmapTexture texture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, currentPerson.texture_src);
        texture.load();
        ITextureRegion personRegion = TextureRegionFactory.extractFromTexture(texture, 0, 0, game.PERSON_TILE_WIDTH, game.PERSON_TILE_HEIGHT);

        block = new ButtonSprite(this.getWidth()/2, py, personRegion, PhoeniciaContext.vboManager);

        personName = new Text(block.getWidth()/2, -16, GameFonts.dialogText(), session.session_name.get(), session.session_name.get().length(),  new TextOptions(AutoWrap.WORDS, 256, HorizontalAlign.CENTER), PhoeniciaContext.vboManager);
        //block.attachChild(personName);

        Texture newShell = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, session_locale.shell_src);
        newShell.load();
        final int GU = 96;
        ITextureRegion levelRegion = TextureRegionFactory.extractFromTexture(newShell, GU*5, GU*0, GU*3, GU*1);
        final ButtonSprite levelIcon = new ButtonSprite(block.getWidth()/2, (0 - levelRegion.getHeight()/2), levelRegion, PhoeniciaContext.vboManager);
        String current_level = session.current_level.get();
        if (current_level == null) current_level = "0";
        final Text levelName = new Text(160, levelIcon.getHeight()/2, GameFonts.defaultHUDDisplay(), current_level, 4, PhoeniciaContext.vboManager);
        levelIcon.attachChild(levelName);
        block.attachChild(levelIcon);

        this.attachChild(block);

    } catch (final IOException e) {
        Debug.e("Failed to load game session person!", e);
    }

    clickDetector = new ClickDetector(this);
    holdDetector = new HoldDetector(this);
    holdDetector.setTriggerHoldMinimumMilliseconds(2000);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:55,代码来源:SessionSelectionScene.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Prepare类代码示例发布时间:2022-05-22
下一篇:
Java PreferenceArray类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap