本文整理汇总了Java中org.andengine.entity.IEntity类的典型用法代码示例。如果您正苦于以下问题:Java IEntity类的具体用法?Java IEntity怎么用?Java IEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IEntity类属于org.andengine.entity包,在下文中一共展示了IEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdate
import org.andengine.entity.IEntity; //导入依赖的package包/类
@Override
public void onUpdate(final float pSecondsElapsed) {
final IEntity entity = this.mEntity;
final Body body = this.mBody;
if (this.mUpdatePosition) {
final Vector2 position = body.getPosition();
final float pixelToMeterRatio = this.mPixelToMeterRatio;
entity.setPosition(position.x * pixelToMeterRatio, position.y * pixelToMeterRatio);
}
if (this.mUpdateRotation) {
final float angle = body.getAngle();
entity.setRotation(-MathUtils.radToDeg(angle));
}
}
示例2: draw
import org.andengine.entity.IEntity; //导入依赖的package包/类
/**
* @see {@link SpriteBatchVertexBufferObject#add(ITextureRegion, float, float, float, float, float, float, float, float)} {@link SpriteBatchVertexBufferObject#add(ITextureRegion, float, float, Transformation, float, float, float, float)}.
*/
public void draw(final ITextureRegion pTextureRegion, final IEntity pEntity, final float pRed, final float pGreen, final float pBlue, final float pAlpha) {
if (pEntity.isVisible()) {
this.assertCapacity();
this.assertTexture(pTextureRegion);
if (pEntity.isRotatedOrScaledOrSkewed()) {
this.add(pTextureRegion, pEntity.getWidth(), pEntity.getHeight(), pEntity.getLocalToParentTransformation(), pRed, pGreen, pBlue, pAlpha);
} else {
this.add(pTextureRegion, pEntity.getX(), pEntity.getY(), pEntity.getWidth(), pEntity.getHeight(), pRed, pGreen, pBlue, pAlpha);
}
this.mIndex++;
}
}
示例3: onUpdate
import org.andengine.entity.IEntity; //导入依赖的package包/类
@Override
protected void onUpdate(final float pSecondsElapsed, final IEntity pEntity) {
if (this.mEnabled) {
/* Apply linear acceleration. */
final float accelerationX = this.mAccelerationX;
final float accelerationY = this.mAccelerationY;
if (accelerationX != 0 || accelerationY != 0) {
this.mVelocityX += accelerationX * pSecondsElapsed;
this.mVelocityY += accelerationY * pSecondsElapsed;
}
/* Apply angular velocity. */
final float angularVelocity = this.mAngularVelocity;
if (angularVelocity != 0) {
pEntity.setRotation(pEntity.getRotation() + angularVelocity * pSecondsElapsed);
}
/* Apply linear velocity. */
final float velocityX = this.mVelocityX;
final float velocityY = this.mVelocityY;
if (velocityX != 0 || velocityY != 0) {
pEntity.setPosition(pEntity.getX() + velocityX * pSecondsElapsed, pEntity.getY() + velocityY * pSecondsElapsed);
}
}
}
示例4: draw
import org.andengine.entity.IEntity; //导入依赖的package包/类
/**
* @see {@link SpriteBatchVertexBufferObject#add(ITextureRegion, float, float, float, float, float)} {@link SpriteBatchVertexBufferObject#add(ITextureRegion, float, float, Transformation, float, float, float, float)}.
*/
public void draw(final ITextureRegion pTextureRegion, final IEntity pEntity, final float pColorABGRPackedInt) {
if (pEntity.isVisible()) {
this.assertCapacity();
this.assertTexture(pTextureRegion);
if (pEntity.isRotatedOrScaledOrSkewed()) {
this.addWithPackedColor(pTextureRegion, pEntity.getWidth(), pEntity.getHeight(), pEntity.getLocalToParentTransformation(), pColorABGRPackedInt);
} else {
this.addWithPackedColor(pTextureRegion, pEntity.getX(), pEntity.getY(), pEntity.getWidth(), pEntity.getHeight(), pColorABGRPackedInt);
}
this.mIndex++;
}
}
示例5: startElement
import org.andengine.entity.IEntity; //导入依赖的package包/类
@Override
public void startElement(final String pUri, final String pLocalName, final String pQualifiedName, final Attributes pAttributes) throws SAXException {
final String entityName = pLocalName;
final IEntity parent = (this.mParentEntityStack.isEmpty()) ? null : this.mParentEntityStack.getLast();
final IEntityLoader entityLoader = this.mEntityLoaders.get(entityName);
final IEntity entity;
if(entityLoader != null) {
entity = entityLoader.onLoadEntity(entityName, pAttributes);
} else if(this.mDefaultEntityLoader != null) {
entity = this.mDefaultEntityLoader.onLoadEntity(entityName, pAttributes);
} else {
throw new IllegalArgumentException("Unexpected tag: '" + entityName + "'.");
}
if(parent != null && entity != null) {
parent.attachChild(entity);
}
this.mParentEntityStack.addLast(entity);
}
示例6: stop
import org.andengine.entity.IEntity; //导入依赖的package包/类
public void stop() {
for (int i = 0; i < this.getChildCount(); i++) {
IEntity child = this.getChildByIndex(i);
if (child instanceof Enemy) {
((Enemy) child).mState = Enemy.STATE_DEAD;
child.setTag(TowerDefense.TAG_DETACHABLE);
} else if (child instanceof SpawnPoint) {
((SpawnPoint) child).mActive = false;
} else if (child instanceof Round || child instanceof SelectionWheel || child instanceof Option) {
child.setTag(TowerDefense.TAG_DETACHABLE);
} else if (child instanceof BasePoint || child instanceof Tower) {
this.unregisterTouchArea((ITouchArea) child);
}
}
this.mWaveTimer.mActive = false;
this.stopMusic();
this.mEnded = true;
}
示例7: show
import org.andengine.entity.IEntity; //导入依赖的package包/类
@Override
public void show() {
this.levelStar.registerEntityModifier(new ScaleModifier(0.4f, 3.0f, 0.75f) {
@Override
protected void onModifierFinished(IEntity pItem) {
super.onModifierFinished(pItem);
}
});
GameSounds.play(GameSounds.COMPLETE);
}
示例8: recalculateContentBounds
import org.andengine.entity.IEntity; //导入依赖的package包/类
/**
* Recalculate the ChildRect values for child Entities
* Whenever an Entity is added or removed from the Scrollable, it's ChildRect needs to be
* re-calculated to find the new boundary rectangle that will contain them
*/
private void recalculateContentBounds() {
this.childRect.set(0, 0, 0, 0);
for(int i = 0; i < this.contents.getChildCount(); i++) {
IEntity child = this.contents.getChildByIndex(i);
//Debug.d("Scrollable Recalculating with child: "+child);
final float childLeft = child.getX()-(child.getWidth()/2)-this.padding;
final float childRight = child.getX()+(child.getWidth()/2)+this.padding;
final float childBottom = child.getY()-(child.getHeight()/2)-this.padding;
final float childTop = child.getY()+(child.getHeight()/2)+this.padding;
if (childLeft < this.childRect.left) { this.childRect.left = childLeft; }
if (childRight > this.childRect.right) { this.childRect.right = childRight; }
if (childTop > this.childRect.top) { this.childRect.top = childTop; }
if (childBottom < this.childRect.bottom) { this.childRect.bottom = childBottom; }
}
//Debug.d("Scrollable childRect: x(" + this.childRect.left + "," + this.childRect.right + ") y(" + this.childRect.bottom + "," + this.childRect.top + ")");
this.contents.setWidth(this.childRect.getWidth());
this.contents.setHeight(this.childRect.getHeight());
this.contents.setPosition(this.childRect.getWidth() / 2, this.childRect.getHeight() / 2);
float new_height = this.getHeight() * (this.getHeight() / this.contents.getHeight());
this.vertical_scrollbar.setSize(scrollbar_size, new_height);
this.vertical_scrollbar.setPosition(this.vertical_scrollbar.getX(), this.getHeight()-(this.vertical_scrollbar.getHeight()/2)-this.scroll_y);
if (this.vertical_scrollbar.getHeight() >= this.getHeight() || this.scroll_lock == SCROLL_HORIZONTAL) {
this.vertical_scrollbar.setVisible(false);
} else {
this.vertical_scrollbar.setVisible(true);
}
float new_width = this.getWidth() * (this.getWidth() / this.contents.getWidth());
this.horizontal_scrollbar.setSize(new_width, scrollbar_size);
this.horizontal_scrollbar.setPosition((this.horizontal_scrollbar.getWidth()/2)+scroll_x, this.horizontal_scrollbar.getY());
if (this.horizontal_scrollbar.getWidth() >= this.getWidth() || this.scroll_lock == SCROLL_VERTICAL) {
this.horizontal_scrollbar.setVisible(false);
} else {
this.horizontal_scrollbar.setVisible(true);
}
}
示例9: onAttached
import org.andengine.entity.IEntity; //导入依赖的package包/类
/**
* Because clipping uses different coordinate transformation depending on whether the Scrollable
* is in a normal Scene or a HUD, we have to check where this Scrollable is being attached and
* set the isInHUD member appropriately.
*/
@Override
public void onAttached() {
IEntity node = this;
while (node.hasParent()) {
node = node.getParent();
if (node instanceof HUD || node instanceof CameraScene) {
this.isInHUD = true;
return;
}
}
}
示例10: doInBackground
import org.andengine.entity.IEntity; //导入依赖的package包/类
@Override
protected Sprite doInBackground(final String... params) {
try {
ITexture mTexture = new BitmapTexture(engine.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
URL url = new URL(params[0]);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
return new BufferedInputStream(input);
}
});
mTexture.load();
textureRegionAnotherPlayer = TextureRegionFactory.extractFromTexture(mTexture);
if (GameManager.getInstance() != null && GameManager.getInstance().players != null &&
GameManager.getInstance().players.length > 0 && engine != null) {
IEntity entity = GameManager.getInstance().players[1].tabSprite;
Sprite user = new Sprite(0, 0, textureRegionAnotherPlayer, engine.getVertexBufferObjectManager());
user.setWidth(entity.getHeight() - 27);
user.setHeight(entity.getHeight() - 27);
user.setX(-13 + entity.getWidth() / 2);
user.setY(+4 + entity.getHeight() / 2);
return user;
}
} catch (IOException e) {
Debug.e(e);
}
return null;
}
示例11: detachGarbage
import org.andengine.entity.IEntity; //导入依赖的package包/类
public void detachGarbage() {
for (int i = 0; i < this.getChildCount(); i++) {
IEntity child = this.getChildByIndex(i);
if (child != null && child.getTag() == TowerDefense.TAG_DETACHABLE) {
this.detachChild(child);
}
}
}
示例12: createItem
import org.andengine.entity.IEntity; //导入依赖的package包/类
private void createItem(float posX, float posY, ITiledTextureRegion textureRegion, Item.Type type) {
Item item = new Item(type, textureRegion, posX, posY, this);
items.add(item);
final Scene gameScene = activity.getScene();
final IEntity layerBG = gameScene.getChildByIndex(PortraitGameActivity.LAYER_BACKGROUND);
final TouchableAnimatedSprite sprite = item.getSprite();
sprite.setVisible(true);
layerBG.attachChild(sprite);
layerBG.attachChild(item.getShape());
gameScene.registerTouchArea(item.getShape());
}
示例13: createBackground
import org.andengine.entity.IEntity; //导入依赖的package包/类
private void createBackground(Scene scene) {
final SmoothCamera camera = activity.getCamera();
final VertexBufferObjectManager vbom = activity.getVBOM();
final ITiledTextureRegion texFlow = activity.getTexture(ResMan.GUT_FLOW);
final IEntity layerBG = scene.getChildByIndex(AbstractGameActivity.LAYER_BACKGROUND);
scene.setBackground(new SpriteBackground(new Sprite(0, 0, camera.getWidth(), camera.getHeight(),
activity.getTexture(ResMan.GUT_BG), vbom)));
for (int i = 0; i < 4; i++) {
layerBG.attachChild(new Flow(POS_FLOW[i], texFlow, vbom).getSprite());
}
}
示例14: drawWithoutChecks
import org.andengine.entity.IEntity; //导入依赖的package包/类
public void drawWithoutChecks(final ITextureRegion pTextureRegion, final IEntity pEntity, final float pWidth, final float pHeight, final float pColorABGRPackedInt) {
if(pEntity.isVisible()) {
if(pEntity.isRotatedOrScaledOrSkewed()) {
this.addWithPackedColor(pTextureRegion, pWidth, pHeight, pEntity.getLocalToParentTransformation(), pColorABGRPackedInt);
} else {
this.addWithPackedColor(pTextureRegion, pEntity.getX(), pEntity.getY(), pWidth, pHeight, pColorABGRPackedInt);
}
this.mIndex++;
}
}
示例15: onSetValues
import org.andengine.entity.IEntity; //导入依赖的package包/类
@Override
protected void onSetValues(final IEntity pEntity, final float pPercentageDone, final float pX, final float pY) {
final float fraction = (pPercentageDone * this.mJumpCount) % 1.0f;
final float deltaY = this.mJumpHeight * 4 * fraction * (1 - fraction);
super.onSetValues(pEntity, pPercentageDone, pX, pY - deltaY);
}