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


Java Sprite.setX方法代码示例

本文整理汇总了Java中org.andengine.entity.sprite.Sprite.setX方法的典型用法代码示例。如果您正苦于以下问题:Java Sprite.setX方法的具体用法?Java Sprite.setX怎么用?Java Sprite.setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.andengine.entity.sprite.Sprite的用法示例。


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

示例1: generateDiamond

import org.andengine.entity.sprite.Sprite; //导入方法依赖的package包/类
/**
 * Generate a diamond centered on the desired position.
 * @param x the x position
 * @param y the y position
 * @return The entity corresponding to the created diamond.
 */
public Entity generateDiamond(float x, float y, float frequency) {
	Sprite sDiamond = new Sprite(x , y, this.spriteLoader.getDiamondTextureRegion(), this.vertextBufferObjectManager);
	sDiamond.setX(sDiamond.getX() - sDiamond.getWidth()/2);
	sDiamond.setY(sDiamond.getY() - sDiamond.getHeight()/2);
	Entity diamond = this.em.createEntity();
	this.em.addComponentToEntity(new SpriteComponent(sDiamond, true), diamond);
	
	Rectangle currLifeRect = new Rectangle(26, 242, 370, 80, this.vertextBufferObjectManager);
	currLifeRect.setColor(0.8f, 0.2f, 0.2f);
	Rectangle maxLifeRect = new Rectangle(26, 242, 370, 80, this.vertextBufferObjectManager);
	maxLifeRect.setColor(0.79f, 0.79f, 0.79f);
	this.em.addComponentToEntity(new DiamondComponent(frequency, 20, currLifeRect, maxLifeRect), diamond);
	
	return diamond;
}
 
开发者ID:Callilf,项目名称:RotatingSentries,代码行数:22,代码来源:EntityFactory.java

示例2: doInBackground

import org.andengine.entity.sprite.Sprite; //导入方法依赖的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;
}
 
开发者ID:viniciusDSL,项目名称:One-Cachito,代码行数:35,代码来源:ResourceManager.java

示例3: centerSprite

import org.andengine.entity.sprite.Sprite; //导入方法依赖的package包/类
public static void centerSprite(Sprite sprite) {
	sprite.setX((CAMERA_WIDTH / 2) - (sprite.getWidth() / 2));
	sprite.setY((CAMERA_HEIGHT / 2) - (sprite.getHeight() / 2));
}
 
开发者ID:sunnyshah2894,项目名称:Flappy-Guy,代码行数:5,代码来源:MainActivity.java

示例4: rightAlignSprite

import org.andengine.entity.sprite.Sprite; //导入方法依赖的package包/类
public static void rightAlignSprite( Sprite sprite){
	
	sprite.setX(((CAMERA_WIDTH)*3)/5 - (sprite.getWidth() /2 ));
	sprite.setY((CAMERA_HEIGHT / 2) - (sprite.getHeight() / 2));
}
 
开发者ID:sunnyshah2894,项目名称:Flappy-Guy,代码行数:6,代码来源:MainActivity.java

示例5: placeCenter

import org.andengine.entity.sprite.Sprite; //导入方法依赖的package包/类
public void placeCenter(final Sprite pSprite, final Camera pCamera) {
	pSprite.setX(pCamera.getWidth() / 2 - pSprite.getWidth() / 2);
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:4,代码来源:GameScene.java

示例6: generateSentry

import org.andengine.entity.sprite.Sprite; //导入方法依赖的package包/类
/**
	 * Generate a sentry at the middle of the screen.
	 * @param rotation the start rotation of the sentry
	 * @return The entity corresponding to the created sentry.
	 */
	public Entity generateSentry(int rotation) {
		// Sprite compo
		TiledTextureRegion sentryTexture = spriteLoader.getSentryTextureRegion();
		final AnimatedSprite sSentry = new AnimatedSprite(gameArea.getWidth()/2 - sentryTexture.getWidth()/2, gameArea.getHeight()/2 - sentryTexture.getHeight()/2, 
				sentryTexture, this.vertextBufferObjectManager);
		sSentry.setZIndex(11);
		sSentry.setRotation(rotation);
		sSentry.stopAnimation(0);
		Entity sentry = this.em.createEntity();
		SpriteComponent spriteComponent = new SpriteComponent(sSentry, true).defineRectangularHitbox(108, 10, 55, 70);
		this.em.addComponentToEntity(spriteComponent, sentry);
		this.em.addComponentToEntity(new SelfRotationComponent(3, 0.8f, 0.2f, rotation, true, true), sentry);
		
		//Primary fire compo
		Sprite primaryFireIcon = new Sprite(0, 0, spriteLoader.getFireIconPrimaryStandardTextureRegion(), this.vertextBufferObjectManager);
		this.em.addComponentToEntity(new PrimaryShootingComponent(primaryFireIcon, ProjectileType.STANDARD, 0.5f, 
				SpriteAnimationEnum.SENTRY_STANDARD_SHOOT.getFrames(), 
				SpriteAnimationEnum.SENTRY_STANDARD_SHOOT.getFrameDurations()), sentry);
		
		
//		//Secondary fire compo
//		//Secondary shooting test :
//		Sprite secondaryFireIcon = new Sprite(0, 0, spriteLoader.getFireIconSecondaryPiercingTextureRegion(), this.vertextBufferObjectManager);
//		Text ammoText = new Text(0, 0, spriteLoader.getSecondaryAmmoFont(), "999", new TextOptions(HorizontalAlign.RIGHT), this.vertextBufferObjectManager);
//		this.em.addComponentToEntity(new SecondaryShootingComponent(secondaryFireIcon, 50, ammoText, ProjectileType.PIERCING, 0.1f, 
//				SpriteAnimationEnum.SENTRY_STANDARD_SHOOT.getFrames(), 
//				SpriteAnimationEnum.SENTRY_STANDARD_SHOOT.getFrameDurations()), sentry);
		
		//Secondary mine test :
		Sprite secondaryMineIcon = new Sprite(0, 0, spriteLoader.getFireIconSecondaryMineTextureRegion(), this.vertextBufferObjectManager);
		Sprite targetSprite = new Sprite(0, 0, spriteLoader.getTargetTextureRegion(), this.vertextBufferObjectManager);
		Text ammoText = new Text(0, 0, spriteLoader.getSecondaryAmmoFont(), "999", new TextOptions(HorizontalAlign.RIGHT), this.vertextBufferObjectManager);
		this.em.addComponentToEntity(new SecondaryMineComponent(secondaryMineIcon, 10, ammoText, targetSprite), sentry);
		
		//AOE attack compo
		Rectangle hitbox = (Rectangle)spriteComponent.getHitbox();
		final AnimatedSprite sElectricAttack = new AnimatedSprite(0, 0, this.spriteLoader.getSentryElectricAttackTextureRegion(), this.vertextBufferObjectManager);
		sElectricAttack.setX(hitbox.getX() + hitbox.getWidth()/2 - sElectricAttack.getWidth()/2);
		sElectricAttack.setY(hitbox.getY() + hitbox.getHeight()/2 - sElectricAttack.getHeight()/2);
		sElectricAttack.setVisible(false);
		sSentry.attachChild(sElectricAttack);
		final Sprite sElectricAttackIcon = new Sprite(0, 0, this.spriteLoader.getSkillElectricityTextureRegion(), this.vertextBufferObjectManager);
		final Sprite sElectricAttackIconFrame = new Sprite(0, 0, this.spriteLoader.getSkillFrameTextureRegion(), this.vertextBufferObjectManager);
		//Temp : placing the icon on the top right of the HUD
		sElectricAttackIconFrame.setX(1508);
		sElectricAttackIconFrame.setY(10);
		sElectricAttackIcon.setX(1508);
		sElectricAttackIcon.setY(10);
		this.em.addComponentToEntity(new AOEAttackComponent(sElectricAttack, sElectricAttackIcon, sElectricAttackIconFrame, hitbox, 5, 2, this.vertextBufferObjectManager), sentry);
		
		//Detectable compo
		this.em.addComponentToEntity(new DetectableComponent(), sentry);
		return sentry;
	}
 
开发者ID:Callilf,项目名称:RotatingSentries,代码行数:60,代码来源:EntityFactory.java


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