當前位置: 首頁>>代碼示例>>Java>>正文


Java AtlasRegion類代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion的典型用法代碼示例。如果您正苦於以下問題:Java AtlasRegion類的具體用法?Java AtlasRegion怎麽用?Java AtlasRegion使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AtlasRegion類屬於com.badlogic.gdx.graphics.g2d.TextureAtlas包,在下文中一共展示了AtlasRegion類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addSpriteFrameWithTextureAtlas

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
/**
 * 讀取gdx textureAtlas文件
 * @param filePath atlas 文件路徑 也可以自定義
 * @param atlas
 */
public void addSpriteFrameWithTextureAtlas(String filePath, TextureAtlas atlas) {
	if(_atlases.containsKey(filePath)) {
		CCLog.debug(this.getClass(), "file loaded : " + filePath);
		return;
	}
	
	_atlases.put(filePath, atlas);
	
	Array<AtlasRegion> rs = atlas.getRegions();
	for(AtlasRegion r : rs) {
		TextureRegion ret = _spriteFrames.put(r.name, r);
		if(ret != null) {
			CCLog.debug(this.getClass(), "region name exists : " + r.name);
		}
	}
}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:22,代碼來源:SpriteFrameCache.java

示例2: createRope

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
private void createRope(Body bodyA, Vector2 anchorA, Body bodyB, Vector2 anchorB, float sag, AtlasRegion ropeRegion)
{
    RopeJointDef jd = new RopeJointDef();
    jd.bodyA = bodyA;
    jd.bodyB = bodyB;
    jd.localAnchorA.set(anchorA.x, anchorA.y);
    jd.localAnchorB.set(anchorB.x, anchorB.y);	    
    // Max length of joint = current distance between bodies * sag
    float ropeLength =  bodyA.getWorldPoint(anchorA).sub(bodyB.getWorldPoint(anchorB)).len() * sag;
    jd.maxLength = ropeLength;
    
    // Create joint
    RopeJoint joint = (RopeJoint)world.createJoint(jd);
    GdxRopeJoint ropeJoint = new GdxRopeJoint(joint, jd.localAnchorA, jd.localAnchorB);
    
    VRope newRope = new VRope(ropeJoint, this, ropeRegion);
    
    ropes.add(newRope);
}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:20,代碼來源:Rope.java

示例3: VRope

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
public VRope(GdxRopeJoint aJoint,
				Group group, AtlasRegion region,
	           //(CCSpriteBatchNode*)spriteSheetArg
	                List<VPoint> points,
	                List<VStick> sticks,
	                List<Image> sprites) {
		
	        joint = aJoint;
//	        spriteSheet = spriteSheetArg;
	        this.group = group;
	        this.region = region;
	        
	        vPoints = points;
	        vSticks = sticks;
	        ropeSprites = sprites;
	        numPoints = vPoints.size();
	}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:18,代碼來源:VRope.java

示例4: getSprite

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
AtlasRegion getSprite(int spriteIndex, boolean isOverlapSprite, Tile tile, float timeElapsed) {
	if(!isOverlapSprite && tileType != tile.getGroundType() && tileType != tile.getSurfaceType())
		System.err.println("Warning: fetching sprite for tile "+tile+" that doesn't have the intended type " + tileType);
	
	Array<AtlasRegion> frames;
	String typeName = tileType.name().toLowerCase();
	String indexString = (spriteIndex < 10 ? "0" : "") + spriteIndex;
	if(isOverlapSprite) {
		frames = tileOverlapAnimations.get(typeName).get(indexString);
		return overlay.getSprite(tile, frames, (int)(timeElapsed/overlayFrameTime));
	} else {
		frames = tileConnectionAnimations.get(typeName).get(indexString);
		//if(!indexString.equals("00"))
		//	System.out.println("fetching sprites for " + typeName + " at " + indexString + " as a connection sprite, from the main animation type " + main + "; frames="+frames);
		return main.getSprite(tile, frames, (int)(timeElapsed/mainFrameTime));
	}
}
 
開發者ID:chrisj42,項目名稱:miniventure,代碼行數:18,代碼來源:AnimationProperty.java

示例5: create

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
@Override
public void create () {
	entityAtlas = new TextureAtlas("sprites/entities.txt");
	tileAtlas = new TextureAtlas("sprites/tiles.txt");
	tileConnectionAtlas = new TextureAtlas("sprites/tileconnectmap.txt");
	iconAtlas = new TextureAtlas("sprites/icons.txt");
	batch = new SpriteBatch();
	font = new BitmapFont(); // uses libGDX's default Arial font
	
	for(AtlasRegion region: iconAtlas.getRegions())
		icons.put(region.name, region);
	
	game = this;
	
	this.setScreen(new MainMenuScreen());
}
 
開發者ID:chrisj42,項目名稱:miniventure,代碼行數:17,代碼來源:GameCore.java

示例6: setRegion

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
public void setRegion (TextureRegion region) {
	if (region == null) throw new IllegalArgumentException("region cannot be null.");
	this.region = region;
	float[] vertices = this.vertices;
	if (region instanceof AtlasRegion && ((AtlasRegion)region).rotate) {
		vertices[U3] = region.getU();
		vertices[V3] = region.getV2();
		vertices[U4] = region.getU();
		vertices[V4] = region.getV();
		vertices[U1] = region.getU2();
		vertices[V1] = region.getV();
		vertices[U2] = region.getU2();
		vertices[V2] = region.getV2();
	} else {
		vertices[U2] = region.getU();
		vertices[V2] = region.getV2();
		vertices[U3] = region.getU();
		vertices[V3] = region.getV();
		vertices[U4] = region.getU2();
		vertices[V4] = region.getV();
		vertices[U1] = region.getU2();
		vertices[V1] = region.getV2();
	}
}
 
開發者ID:laurencegw,項目名稱:jenjin,代碼行數:25,代碼來源:RegionAttachment.java

示例7: AnimatedSprite

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
public AnimatedSprite(String key, float totalDuration, Integer numLoops, State state) {
    super();

    Array<AtlasRegion> frames = AssetManager.getInstance().getTextureRegions(key);
    float frameDuration = ConversionUtils.ms2s(totalDuration / frames.size);
    rawAnimation = new Animation(frameDuration, frames);

    this.numLoops = numLoops;
    if (numLoops == null || numLoops > 1) {
        rawAnimation.setPlayMode(PlayMode.LOOP);
    }

    this.state = state;

    setRegion(getCurrentFrame());
}
 
開發者ID:alexschimpf,項目名稱:joe,代碼行數:17,代碼來源:AnimatedSprite.java

示例8: act

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
@Override
public void act(float delta) {
    super.act(delta);

    PageGroup pp = PageGroup.this;
    Vector2 pointerPos = pp.screenToLocal(Gdx.input.getX(), Gdx.input.getY());
    boolean withinPage = tmpBounds.set(0f, 0f, pp.getWidth(), pp.getHeight()).contains(pointerPos);

    if (!withinPage && active) {
        clearSpotlight();
    }

    if (withinPage) {
        AtlasRegion region = hitRegion(pointerPos);
        if (region != null) {
            spotlightRegion(region);
        }

        if (region == null && active) {
            clearSpotlight();
        }
    }
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:24,代碼來源:PageGroup.java

示例9: spotlightRegion

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
private void spotlightRegion(AtlasRegion region) {
    if (this.region == region) return;

    this.region = region;
    active = true;

    // You can customize what is shown when user hover on region in here
    StringBuilder sb = new StringBuilder();
    sb.append(region.name);
    if (region.index >= 0) {
        sb.append("[#fbf236ff] idx:" + region.index);
    }

    font.getData().setScale(1f);
    glText.setText(font, sb.toString(), Color.WHITE, 0f, Align.left, false);
}
 
開發者ID:crashinvaders,項目名稱:gdx-texture-packer-gui,代碼行數:17,代碼來源:PageGroup.java

示例10: GigaGalAssets

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
public GigaGalAssets(TextureAtlas atlas) {
    standingLeft = atlas.findRegion(Constants.STANDING_LEFT);
    standingRight = atlas.findRegion(Constants.STANDING_RIGHT);
    walkingLeft = atlas.findRegion(Constants.WALKING_LEFT_2);
    walkingRight = atlas.findRegion(Constants.WALKING_RIGHT_2);

    jumpingLeft = atlas.findRegion(Constants.JUMPING_LEFT);
    jumpingRight = atlas.findRegion(Constants.JUMPING_RIGHT);

    Array<AtlasRegion> walkingLeftFrames = new Array<AtlasRegion>();
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_1));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_2));
    walkingLeftFrames.add(atlas.findRegion(Constants.WALKING_LEFT_3));
    walkingLeftAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingLeftFrames, PlayMode.LOOP);

    Array<AtlasRegion> walkingRightFrames = new Array<AtlasRegion>();
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_1));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_2));
    walkingRightFrames.add(atlas.findRegion(Constants.WALKING_RIGHT_3));
    walkingRightAnimation = new Animation(Constants.WALK_LOOP_DURATION, walkingRightFrames, PlayMode.LOOP);
}
 
開發者ID:udacity,項目名稱:ud406,代碼行數:24,代碼來源:Assets.java

示例11: ExitPortalAssets

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
public ExitPortalAssets(TextureAtlas atlas) {
    final AtlasRegion exitPortal1 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_1);
    final AtlasRegion exitPortal2 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_2);
    final AtlasRegion exitPortal3 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_3);
    final AtlasRegion exitPortal4 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_4);
    final AtlasRegion exitPortal5 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_5);
    final AtlasRegion exitPortal6 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_6);

    Array<AtlasRegion> exitPortalFrames = new Array<AtlasRegion>();

    // TODO: Add the frames to the exitPortalFrames array
    exitPortalFrames.addAll(exitPortal1, exitPortal2, exitPortal3, exitPortal4, exitPortal5, exitPortal6);

    // TODO: Package the frames into an animation, using the frame duration constant
    // Go define that constant in Constants.java if you haven't already
    exitPortal = new Animation(Constants.EXIT_PORTAL_FRAME_DURATION, exitPortalFrames);
}
 
開發者ID:udacity,項目名稱:ud406,代碼行數:18,代碼來源:Assets.java

示例12: loadAnimatedSprite

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
/**
 * loads a specific animated sprite. The loaded sprite can then be retrieved with the 
 * getAnimatedSprite() method.
 * Increases the accesscounter of the sprite if already loaded.
 * 
 * @param texture type of texture to be used for the sprite
 */
public void loadAnimatedSprite(TextureType texture) {
	// check if texture atlas map contains the atlas type that should be used 
	if (spriteMap != null && !spriteMap.containsKey(texture) && textureAtlasMap != null && textureAtlasMap.containsKey(texture.getTextureAtlasPath())) {
		// check if the atlas regions were successfully loaded for the texture atlas
		TextureAtlas textureAtlas = textureAtlasMap.get(texture.getTextureAtlasPath()).getResource();
		if (atlasRegionMap != null && atlasRegionMap.containsKey(textureAtlas)) {
			Map<TextureType, AtlasRegion> regionMap = atlasRegionMap.get(textureAtlas);
			if (regionMap != null && regionMap.containsKey(texture)) {
				// create sprite out of texture atlas region's texture
				AnimatedSprite animatedSprite = new AnimatedSprite(regionMap.get(texture), texture);
				spriteMap.put(texture, new Resource<AnimatedSprite>(animatedSprite));
			}
		} else {
			Gdx.app.log(GameConstants.LOG_TAG_INFO, "TextureAtlas does not contain region: " + texture.getAtlasRegionName());
		}
	} else {
		// increase resource counter
		spriteMap.get(texture).incCounter();
	}
}
 
開發者ID:Quillraven,項目名稱:Protoman-vs-Megaman,代碼行數:28,代碼來源:ResourceManager.java

示例13: ExitPortalAssets

import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; //導入依賴的package包/類
public ExitPortalAssets(TextureAtlas atlas) {
    final AtlasRegion exitPortal1 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_1);
    final AtlasRegion exitPortal2 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_2);
    final AtlasRegion exitPortal3 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_3);
    final AtlasRegion exitPortal4 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_4);
    final AtlasRegion exitPortal5 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_5);
    final AtlasRegion exitPortal6 = atlas.findRegion(Constants.EXIT_PORTAL_SPRITE_6);

    Array<AtlasRegion> exitPortalFrames = new Array<AtlasRegion>();

    // TODO: Add the frames to the exitPortalFrames array


    // TODO: Package the frames into an animation, using the frame duration constant
    // Go define that constant in Constants.java if you haven't already

}
 
開發者ID:udacity,項目名稱:ud406,代碼行數:18,代碼來源:Assets.java


注:本文中的com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。