本文整理汇总了Java中org.andengine.entity.sprite.ButtonSprite类的典型用法代码示例。如果您正苦于以下问题:Java ButtonSprite类的具体用法?Java ButtonSprite怎么用?Java ButtonSprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ButtonSprite类属于org.andengine.entity.sprite包,在下文中一共展示了ButtonSprite类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addButtons
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
@Override
protected void addButtons() {
restartButton = new ButtonSprite(camera.getWidth() - 300, (camera.getHeight() - 300),
resourcesManager.restartRegion, vbom, new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY) {
storyService.loadGameSceneFromGameScene(levelBackup);
}
});
restartButton.setWidth(300);
restartButton.setHeight(300);
registerTouchArea(restartButton);
attachChild(restartButton);
}
开发者ID:djschilling,项目名称:sopa,代码行数:18,代码来源:LevelModeGameScene.java
示例2: addButtons
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
@Override
protected void addButtons() {
restartButton = new ButtonSprite(camera.getWidth() - 300, (camera.getHeight() - 300),
resourcesManager.restartRegion, vbom, new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY) {
storyService.loadJustPlaySceneFromJustPlayScene(timeBasedGameService,
new JustPlayLevel(timeBasedGameService.getRemainingTime(), levelBackup));
}
});
restartButton.setWidth(300);
restartButton.setHeight(300);
registerTouchArea(restartButton);
attachChild(restartButton);
}
开发者ID:djschilling,项目名称:sopa,代码行数:19,代码来源:JustPlayGameScene.java
示例3: nextScenario
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
/**
* 次シナリオへ
*/
public void nextScenario() {
// FPS表示以外を開放
for (int i = 0; i < getChildCount(); i++) {
if (getChildByIndex(i).getTag() == FPS_TAG) {
continue;
}
// ボタンはタッチの検知も無効にする
if (getChildByIndex(i) instanceof ButtonSprite) {
unregisterTouchArea((ButtonSprite) getChildByIndex(i));
}
detachEntity(getChildByIndex(i));
}
System.gc();
// セーブAnd次シナリオへ進行
getBaseActivity().getGameController().nextScenarioAndSave(this);
init();
}
开发者ID:kyokomi,项目名称:AndEngineSRPGQuest,代码行数:22,代码来源:SrpgBaseScene.java
示例4: onClick
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
@Override
public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX,
float pTouchAreaLocalY) {
// // 効果音を再生
// getMediaManager().play(SoundType.BTN_PRESSED_SE);
// // BGMなどをリセット
// getMediaManager().resetAllMedia();
switch (pButtonSprite.getTag()) {
case SAVE_LOAD: // シナリオデータ読み込み
showScene(new MainScene(getBaseActivity()));
break;
case NEW_GAME: // NewGame
getBaseActivity().getGameController().start(getBaseActivity());
showScene(new MainScene(getBaseActivity()));
break;
}
}
开发者ID:kyokomi,项目名称:AndEngineSRPGQuest,代码行数:19,代码来源:InitialScene.java
示例5: showSelectMenu
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
public void showSelectMenu(KeyListenScene pBaseScene, float x, float y,
boolean isAttackDone, boolean isMovedDone) {
// 配置
setCalcPosition(pBaseScene, x, y);
// 攻撃
IEntity attackMenuItem = getChildByTag(SelectMenuType.SELECT_MENU_ATTACK_TYPE.getValue());
if (attackMenuItem instanceof ButtonSprite) {
((ButtonSprite) attackMenuItem).setEnabled(!isAttackDone);
((ButtonSprite) attackMenuItem).setVisible(!isAttackDone); // 非活性ボタンがあればイラナイ
}
// 移動
IEntity moveMenuItem = getChildByTag(SelectMenuType.SELECT_MENU_MOVE_TYPE.getValue());
if (moveMenuItem instanceof ButtonSprite) {
((ButtonSprite) moveMenuItem).setEnabled(!isMovedDone);
((ButtonSprite) moveMenuItem).setVisible(!isMovedDone); // 非活性ボタンがあればイラナイ
}
// 表示
setEnabled(true);
setVisible(true);
}
开发者ID:kyokomi,项目名称:AndEngineSRPGQuest,代码行数:23,代码来源:MapBattleSelectMenuLayer.java
示例6: AboutMenuScene
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
public AboutMenuScene(){
setBackground(new Background(0.09804f, 0.6274f, 0.8784f));
Sprite AboutBoard = new Sprite(activity.getCameraWidth() / 2, activity.getCameraHeight() / 2, activity.mAboutBoardTextureRegion, activity.getVertexBufferObjectManager());
AboutBoard.setSize(activity.getCameraWidth(), activity.getCameraHeight());
attachChild(AboutBoard);
final Sprite HomeMenuItem = new ButtonSprite(activity.getCameraWidth() / 2, activity.mHomeTextureRegion.getHeight()/2, activity.mHomeTextureRegion, activity.getVertexBufferObjectManager(), new OnClickListener() {
@Override
public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX,
float pTouchAreaLocalY) {
// TODO Auto-generated method stub
activity.setCurrentScene(new MainMenuScene());
}
});
HomeMenuItem.setSize(30, 30);
registerTouchArea(HomeMenuItem);
attachChild(HomeMenuItem);
setTouchAreaBindingOnActionDownEnabled(true);
}
开发者ID:erisazani,项目名称:MissionInsectible,代码行数:24,代码来源:AboutMenuScene.java
示例7: HelpMenuScene
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
public HelpMenuScene(){
setBackground(new Background(0.09804f, 0.6274f, 0.8784f));
Sprite HowToBoard = new Sprite(activity.getCameraWidth() / 2, activity.getCameraHeight() / 2, activity.mHowToBoardTextureRegion, activity.getVertexBufferObjectManager());
HowToBoard.setSize(activity.getCameraWidth(), activity.getCameraHeight());
attachChild(HowToBoard);
final Sprite HomeMenuItem = new ButtonSprite(activity.getCameraWidth()/2,activity.mHomeTextureRegion.getHeight()/2, activity.mHomeTextureRegion, activity.getVertexBufferObjectManager(), new OnClickListener() {
@Override
public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX,
float pTouchAreaLocalY) {
// TODO Auto-generated method stub
activity.setCurrentScene(new MainMenuScene());
}
});
HomeMenuItem.setSize(30, 30);
registerTouchArea(HomeMenuItem);
attachChild(HomeMenuItem);
setTouchAreaBindingOnActionDownEnabled(true);
}
开发者ID:erisazani,项目名称:MissionInsectible,代码行数:24,代码来源:HelpMenuScene.java
示例8: showResponseCode
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
public void showResponseCode(final Gift gift) {
int responseCode = gift.responseCode.get();
try {
if (gift.requestType.get() == GiftRequest.LETTER_REQUEST) {
Letter addLetter = game.locale.letters.get(gift.requestItem.get());
game.inventory.subtract(addLetter.name, 1);
} else if (gift.requestType.get() == GiftRequest.WORD_REQUEST) {
Word addWord = game.locale.words.get(gift.requestItem.get());
game.inventory.subtract(addWord.name, 1);
}
} catch (Exception e) {
//TODO: Show error dialog
Debug.d("Could not subtract item, not enough in inventory");
GameSounds.play(GameSounds.FAILED);
return;
}
int startX = (int)(whiteRect.getWidth()/2 - (64 * CODE_LENGTH)/2) + 16;
for (int i = 0; i < CODE_LENGTH; i++) {
int power = (int)(Math.pow(10, CODE_LENGTH-i-1));
Debug.d("Showing response code position: " + power);
int digit = responseCode / power;
Debug.d("Showing response code digit: " + digit);
final Number requestDigit = game.locale.number_map.get(digit);
ButtonSprite digitSprite = new ButtonSprite(startX+(64*i), 96, game.numberSprites.get(requestDigit), PhoeniciaContext.vboManager);
digitSprite.setOnClickListener(new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite buttonSprite, float v, float v1) {
game.playBlockSound(requestDigit.sound);
}
});
whiteRect.attachChild(digitSprite);
this.registerTouchArea(digitSprite);
responseCode -= digit * power;
}
}
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:39,代码来源:SendGiftHUD.java
示例9: addRequestToQueue
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的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: Numberpad
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
public Numberpad(final float pX, final float pY, final float width, final float height, final PhoeniciaGame game) {
super(pX, pY, width, height);
this.game = game;
/**
* Start available numbers area
*/
final int columns = 5;
float startX = 50;
int offsetX = 0;
int offsetY = (int) height-32;
for (int i = 0; i < game.locale.numbers.size(); i++) {
if (offsetX >= columns) {
offsetY -= 80;
offsetX = 0;
}
final Number currentNumber = game.locale.numbers.get(i);
Debug.d("Adding Numberpad number: " + currentNumber.name + " (column: " + offsetX + ")");
final ITiledTextureRegion blockRegion = game.numberSprites.get(currentNumber);
final ButtonSprite block = new ButtonSprite(startX + (96 * offsetX), offsetY, blockRegion, PhoeniciaContext.vboManager);
block.setOnClickListener(new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite buttonSprite, float v, float v2) {
if (listener != null) {
listener.onKeyClicked(currentNumber);
}
}
});
this.registerTouchArea(block);
this.attachChild(block);
offsetX++;
}
}
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:38,代码来源:Numberpad.java
示例11: addBackToMenuButton
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
private void addBackToMenuButton() {
ButtonSprite backToMenuButton = new ButtonSprite(0, (camera.getHeight() - 400),
resourcesManager.backToMenuRegionP, vbom, new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY) {
onBackKeyPressed();
}
});
attachChild(backToMenuButton);
registerTouchArea(backToMenuButton);
}
开发者ID:djschilling,项目名称:sopa,代码行数:15,代码来源:JustPlayLostScene.java
示例12: addNextLevelButton
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
private void addNextLevelButton() {
ButtonSprite nextLevelButton = new ButtonSprite((camera.getWidth() / 2 - 200), (camera.getHeight() - 400),
resourcesManager.nextJustPlayLevel, vbom, new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY) {
storyService.loadJustPlaySceneFromJustPlayScoreScene();
}
});
attachChild(nextLevelButton);
registerTouchArea(nextLevelButton);
}
开发者ID:djschilling,项目名称:sopa,代码行数:15,代码来源:JustPlayScoreScene.java
示例13: creatButtonWithAddMenu
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
private ButtonSprite creatButtonWithAddMenu(KeyListenScene pBaseScene, SelectMenuType pSelectMenuType) {
ButtonSprite btnSprite = pBaseScene.getResourceButtonSprite(
pSelectMenuType.getNormalFileName(),
pSelectMenuType.getPressedFileName());
addMenuItem(pSelectMenuType.getValue(), btnSprite);
btnSprite.setOnClickListener(selectMenuOnClickListener);
return btnSprite;
}
开发者ID:kyokomi,项目名称:AndEngineSRPGQuest,代码行数:9,代码来源:MapBattleSelectMenuLayer.java
示例14: attachButtonSprite
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
/**
* ボタンの配置.
* @param baseEntity 配置先
* @param tag 押下時のメニュー判断用のタグ
* @param buttonSprite 配置するボタン
* @param y 配置するY座標
* @param listener 押下時のイベントリスナー
*/
public void attachButtonSprite(final IEntity baseEntity, int tag,
ButtonSprite buttonSprite, int y, final OnClickListener listener) {
placeToCenterX(buttonSprite, y);
buttonSprite.setTag(tag);
buttonSprite.setOnClickListener(listener);
baseEntity.attachChild(buttonSprite);
registerTouchArea(buttonSprite);
}
开发者ID:kyokomi,项目名称:AndEngineSRPGQuest,代码行数:17,代码来源:KeyListenScene.java
示例15: SessionSprite
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的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
示例16: show_round
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
private void show_round(int round) {
int word_index = round % this.max_rounds;
final Word challenge_word = this.random_word_list.get(word_index);
// Take the challenge word out of the list and shuffle it
List<Word> draw_words = new ArrayList<Word>(this.random_word_list);
draw_words.remove(challenge_word);
Collections.shuffle(draw_words);
// Draw max_choices-1 from the list, add the challenge word to it and shuffle again
List<Word> choice_words = draw_words.subList(0, this.max_choices-1);
choice_words.add(challenge_word);
Collections.shuffle(choice_words);
for (int i = 0; i < choice_words.size(); i++) {
final Word word = choice_words.get(i);
float available_width = (this.cardPane.getWidth()/choice_words.size());
final float wordX = i*(this.cardPane.getWidth()/choice_words.size());
final float wordY = this.cardPane.getHeight() - 150;
ITextureRegion sprite_region = this.game.wordSprites.get(word);
ButtonSprite wordSprite = new ButtonSprite(wordX+(available_width/2), wordY, sprite_region, PhoeniciaContext.vboManager, new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite buttonSprite, float v, float v1) {
if (word == challenge_word) {
pass(word, wordX);
} else {
fail(word, wordX);
}
next_round();
}
});
wordSprite.setScale(2.0f);
this.registerTouchArea(wordSprite);
this.touchAreas.add(wordSprite);
this.cardPane.attachChild(wordSprite);
}
Font wordFont = GameFonts.introText();
Text challenge_text = new Text(this.cardPane.getWidth()/2, this.cardPane.getHeight() - 300, wordFont, String.valueOf(challenge_word.chars), challenge_word.chars.length, new TextOptions(HorizontalAlign.CENTER), PhoeniciaContext.vboManager);
challenge_text.setX(this.cardPane.getWidth() / 2);
this.cardPane.attachChild(challenge_text);
}
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:44,代码来源:ImageMatchGameHUD.java
示例17: LevelIntroHUD
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
/**
* Display level transition text pages, images and sound.
* @param game Reference to the PhoeniciaGame this HUD is running in
* @param level The level to display introduction pages for
*/
public LevelIntroHUD(final PhoeniciaGame game, final Level level) {
super(game);
this.setBackgroundEnabled(false);
this.game = game;
this.level = level;
this.current_page = 0;
this.setOnSceneTouchListener(this);
Debug.d("New level guide: "+game.locale.tour.guide.name);
this.guideSprite = new Sprite(-112, 160, game.personTiles.get(game.locale.tour.guide), PhoeniciaContext.vboManager);
this.attachChild(guideSprite);
final float messageBoxWidth = this.getWidth()-this.guideSprite.getWidth()-32;
final float messageBoxHeight = 256;
String texture = "textures/tour/tour-focus-none.png";
try {
final AssetBitmapTexture spotlight_texture = new AssetBitmapTexture(PhoeniciaContext.textureManager, PhoeniciaContext.assetManager, texture);
spotlight_texture.load();
TextureRegion spotlight_region = TextureRegionFactory.extractFromTexture(spotlight_texture);
Sprite backdrop = new Sprite(this.getWidth()/2, this.getHeight()/2, spotlight_region, PhoeniciaContext.vboManager);
backdrop.setZIndex(guideSprite.getZIndex()-1);
this.attachChild(backdrop);
this.sortChildren();
} catch (IOException e) {
Debug.e("Failed to load spotlight texture: "+texture);
}
Debug.d("New Level into guide sprite width: "+this.guideSprite.getWidth());
this.messageBox = new BorderRectangle((messageBoxWidth/2)+this.guideSprite.getWidth(), this.guideSprite.getY(), messageBoxWidth, messageBoxHeight, PhoeniciaContext.vboManager);
this.messageBox.setColor(Color.WHITE);
this.attachChild(messageBox);
this.registerTouchArea(messageBox);
ITextureRegion nextRegion = GameUI.getInstance().getNextIcon();
this.nextButton = new ButtonSprite(messageBox.getWidth() - 48, 50, nextRegion, PhoeniciaContext.vboManager);
this.nextButton.setOnClickListener(new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite buttonSprite, float v, float v1) {
if (current_page+1 < level.intro.size()) {
nextButton.setVisible(false);
showPage(current_page + 1);
} else {
finish();
}
}
});
this.nextButton.setVisible(false);
this.registerTouchArea(this.nextButton);
this.messageBox.attachChild(this.nextButton);
Debug.d("Finished instantiating LevelIntroHUD");
this.clickDetector = new ClickDetector(this);
}
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:59,代码来源:LevelIntroHUD.java
示例18: show_round
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
private void show_round(int round) {
int word_index = round % this.max_rounds;
final Word challenge_word = this.random_word_list.get(word_index);
// Take the challenge word out of the list and shuffle it
List<Word> draw_words = new ArrayList<Word>(this.random_word_list);
draw_words.remove(challenge_word);
Collections.shuffle(draw_words);
// Draw max_choices-1 from the list, add the challenge word to it and shuffle again
List<Word> choice_words = draw_words.subList(0, this.max_choices-1);
choice_words.add(challenge_word);
Collections.shuffle(choice_words);
for (int i = 0; i < choice_words.size(); i++) {
final Word word = choice_words.get(i);
float available_width = (this.cardPane.getWidth()/choice_words.size());
float wordX = i*(this.cardPane.getWidth()/choice_words.size());
float wordY = this.cardPane.getHeight() - 150;
Button wordText = new Button(wordX+(available_width/2), wordY, 200, 100, String.valueOf(word.chars), PhoeniciaContext.vboManager, new Button.OnClickListener() {
@Override
public void onClicked(Button button) {
if (word == challenge_word) {
pass(challenge_word);
} else {
fail(challenge_word);
}
next_round();
}
});
this.registerTouchArea(wordText);
this.touchAreas.add(wordText);
this.cardPane.attachChild(wordText);
}
ITiledTextureRegion sprite_region = this.game.wordSprites.get(challenge_word);
ButtonSprite challenge_sprite = new ButtonSprite(this.cardPane.getWidth()/2, this.cardPane.getHeight() - 300, sprite_region, PhoeniciaContext.vboManager);
challenge_sprite.setOnClickListener(new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite buttonSprite, float v, float v1) {
game.playBlockSound(challenge_word.sound);
}
});
challenge_sprite.setScale(2.0f);
this.cardPane.attachChild(challenge_sprite);
this.registerTouchArea(challenge_sprite);
this.touchAreas.add(challenge_sprite);
}
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:49,代码来源:WordMatchGameHUD.java
示例19: Keyboard
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
public Keyboard(final float pX, final float pY, final float width, final float height, final PhoeniciaGame game, final int details) {
super(pX, pY, width, height);
this.game = game;
this.details = details;
this.inventoryCounts = new HashMap<String, Text>();
this.usedCounts = new HashMap<String, Integer>();
/**
* Start available letters area
*/
final int columns = 8;
float startX = 50;
int offsetX = 0;
int offsetY = (int) height-32;
for (int i = 0; i < game.locale.letters.size(); i++) {
if (offsetX >= columns) {
offsetY -= 80;
offsetX = 0;
}
final Letter currentLetter = game.locale.letters.get(i);
Debug.d("Adding Builder letter: " + currentLetter.name + " (column: " + offsetX + ")");
final int tile_id = currentLetter.sprite;
final ITiledTextureRegion blockRegion = game.letterSprites.get(currentLetter);
final ButtonSprite block = new ButtonSprite(startX + (96 * offsetX), offsetY, blockRegion, PhoeniciaContext.vboManager);
block.setOnClickListener(new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite buttonSprite, float v, float v2) {
if (listener != null) {
listener.onKeyClicked(currentLetter);
}
}
});
this.registerTouchArea(block);
this.attachChild(block);
Level level = game.locale.level_map.get(game.current_level);
if (level.letters.contains(currentLetter)) {
if (this.details == this.SHOW_INVENTORY) {
Debug.d("Checking inventory for " + currentLetter.name);
Debug.d("Inventory says: " + this.game.inventory.getCount(currentLetter.name));
final Text inventoryCount = new Text(startX + (96 * offsetX) + 20, offsetY - 40, GameFonts.inventoryCount(), "" + this.game.inventory.getCount(currentLetter.name), 4, PhoeniciaContext.vboManager);
this.attachChild(inventoryCount);
this.inventoryCounts.put(currentLetter.name, inventoryCount);
this.usedCounts.put(currentLetter.name, 0);
} else if (this.details == this.SHOW_COST) {
final int cost = currentLetter.buy * (int)Math.pow(LetterPlacementHUD.costMultiplier, Assets.getInsance().getLetterTileCount(currentLetter));
final Text letterCost = new Text(startX + (96 * offsetX) - 20, offsetY - 40, GameFonts.itemCost() , "" + cost, 5, PhoeniciaContext.vboManager);
this.attachChild(letterCost);
this.inventoryCounts.put(currentLetter.name, letterCost);
}
} else {
block.setEnabled(false);
}
offsetX++;
}
}
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:62,代码来源:Keyboard.java
示例20: init
import org.andengine.entity.sprite.ButtonSprite; //导入依赖的package包/类
@Override
public void init(SaveDataDto saveDataDto) {
// 初期化
mBattlePart = null;
mActorPlayerLogic = new ActorPlayerLogic();
touchStartPoint = new float[2];
// 背景
initBackground(saveDataDto);
// マップ情報を読み込む
mMapBattleInfoDto = new MapBattleInfoDto();
mMapBattleInfoDto.createMapJsonData(saveDataDto.getSceneId(),
JsonUtil.toJson(getBaseScene().getBaseActivity(), "map/"+ saveDataDto.getSceneId()));
// ベースマップ生成
Rectangle mapBaseRect = new Rectangle(0, 0,
getBaseScene().getWindowWidth(), getBaseScene().getWindowHeight(),
getBaseScene().getBaseActivity().getVertexBufferObjectManager());
mapBaseRect.setTag(9999999); // TODO:どうにかして
mapBaseRect.setColor(Color.TRANSPARENT);
getBaseScene().attachChild(mapBaseRect);
// ダメージテキスト初期化
initDamageText(mapBaseRect);
// グリッド線表示
showGrid(mapBaseRect);
// 選択カーソルを用意
Sprite cursorSprite = createCursorSprite(new Point(0, 0), Color.CYAN);
cursorSprite.setVisible(false);
cursorSprite.setZIndex(LayerZIndexType.SELECTCURSOR_LAYER.getValue());
// タッチレイヤー初期化
MapBattleClearConditionTouchLayer mMapBattleTouchLayer = new MapBattleClearConditionTouchLayer(getBaseScene());
mMapBattleTouchLayer.setTag(MapBattleClearConditionTouchLayer.TAG);
getBaseScene().attachChild(mMapBattleTouchLayer);
// カットイン初期化
attachWithCreateCutInLayer(MapBattleCutInLayerType.PLAYER_TURN_CUTIN);
attachWithCreateCutInLayer(MapBattleCutInLayerType.PLAYER_WIN_CUTIN);
attachWithCreateCutInLayer(MapBattleCutInLayerType.ENEMY_TURN_CUTIN);
attachWithCreateCutInLayer(MapBattleCutInLayerType.GAME_OVER_CUTIN);
// メニュー初期化
mMapBattleSelectMenuLayer = new MapBattleSelectMenuLayer(getBaseScene(), new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX,
float pTouchAreaLocalY) {
getBaseScene().touchSprite(mMapBattleSelectMenuLayer.getX() + pTouchAreaLocalX,
mMapBattleSelectMenuLayer.getY() + pTouchAreaLocalY);
mGameManager.touchMenuBtnEvent(pButtonSprite.getTag());
}
});
// ゲーム開始
mGameManager = new GameManager(mSrpgGameManagerListener);
mGameManager.mapInit(mMapBattleInfoDto); // 10 x 10 スケール1倍のグリッドマップ
startMap(saveDataDto);
}
开发者ID:kyokomi,项目名称:AndEngineSRPGQuest,代码行数:64,代码来源:SRPGPart.java
注:本文中的org.andengine.entity.sprite.ButtonSprite类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论