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


Java Sprite.setSize方法代碼示例

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


在下文中一共展示了Sprite.setSize方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: GameActor

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public GameActor(TextureRegion actor_region,float x_pos,float y_pos,Color color,float width,float height) {
actor_texture = actor_region;
xpos = x_pos ;
ypos = y_pos ;
width_ =width ;
height_ = height;
actor_Sprite = new Sprite(actor_texture);
actor_Sprite.setX(xpos);
actor_Sprite.setY(ypos);
if(color != null){   
actor_Sprite.setColor(color);}
actor_Sprite.setSize(width_, height_);
actor_Sprite.setOrigin(width_/2, height_/2);
setBounds(xpos, ypos, width_, height_);
this.setTouchable(Touchable.enabled);
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:17,代碼來源:GameActor.java

示例2: Trajectory

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public Trajectory(Orbiter orbiter) {
    this.orbiter = orbiter;
    int degreeIncrement = 10;
    speed = 10;

    Array<Orbiter> pathObjects = new Array<Orbiter>();
    for(int i = 0; i < 360; i += degreeIncrement) {
        Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint();
        orbiterBlueprint.angle = i;
        orbiterBlueprint.angularVelocity = speed;
        orbiterBlueprint.radius = orbiter.getRadius();
        orbiterBlueprint.xTilt = orbiter.getXTilt();
        orbiterBlueprint.zTilt = orbiter.getZTilt();

        Sprite trajectoryDot = new Sprite(Scene.pixelTexture);
        Color color = new Color();
        Color.rgba8888ToColor(color, orbiter.getColor());
        trajectoryDot.setColor(color);
        trajectoryDot.setSize(2, 2);

        pathObjects.add(new Orbiter(trajectoryDot, orbiterBlueprint));
    }
    path = new Ring(pathObjects);
}
 
開發者ID:ZKasica,項目名稱:Planet-Generator,代碼行數:25,代碼來源:Trajectory.java

示例3: testStar1Json

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Test
public void testStar1Json() {
    // Test star with size 1
    Sprite sprite = new Sprite();
    sprite.setSize(1, 1);
    Star saveStar = new Star(sprite);
    saveStar.getSprite().setPosition(100, 150);

    String starJson = json.toJson(saveStar);
    assertNotEquals("", starJson);

    Star loadStar = json.fromJson(Star.class, starJson);

    assertNotEquals(null, loadStar);
    assertNotEquals(null, loadStar.getSprite());
    assertEquals(1, loadStar.getSprite().getWidth());
    assertEquals(1, loadStar.getSprite().getHeight());
    assertEquals(100, loadStar.getSprite().getX());
    assertEquals(150, loadStar.getSprite().getY());
}
 
開發者ID:ZKasica,項目名稱:Planet-Generator,代碼行數:21,代碼來源:SavingLoadingTests.java

示例4: testStar2Json

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Test
public void testStar2Json() {
    Sprite sprite = new Sprite();
    Star saveStar = new Star(sprite);
    saveStar.getSprite().setPosition(150, 100);
    sprite.setSize(2, 2);

    String starJson = json.toJson(saveStar);
    assertNotEquals("", starJson);

    Star loadStar = json.fromJson(Star.class, starJson);

    assertNotEquals(null, loadStar);
    assertEquals(2, loadStar.getSprite().getWidth());
    assertEquals(2, loadStar.getSprite().getHeight());
    assertEquals(150, loadStar.getSprite().getX());
    assertEquals(100, loadStar.getSprite().getY());
}
 
開發者ID:ZKasica,項目名稱:Planet-Generator,代碼行數:19,代碼來源:SavingLoadingTests.java

示例5: GozaName

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public GozaName(int goza_no , int page_no) {
	// TODO Auto-generated constructor stub
	goza_name_texture = book.images_textures_atlas.findRegion("s"+goza_no);
	Goza_name_sprite = new Sprite(goza_name_texture);
	width = sorah_name_width ; 
	height = tab_height ;
	Goza_name_sprite.setSize(width, height);
	no = page_no ;
	text_y_deferance=2*tab_height/3;
	x = (sorah_page_no_width+sorah_tanzel_width+ayat_widht)+sorah_tab_book_mark_width*3  ;
	y = book.select_page_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1)));
	
	no_of_surah = new TextActor(page_no+"",
			null,
			tab_no_width,
			TextAlign.align_cinter,tab_no_text_scale,x+sorah_name_width, text_y_deferance+y);
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:18,代碼來源:PageTap.java

示例6: create

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
public void create() {		
	float w = Gdx.graphics.getWidth();
	float h = Gdx.graphics.getHeight();
	
	camera = new OrthographicCamera(1, h/w);
	batch = new SpriteBatch();
	
	texture = new Texture(Gdx.files.internal("data/libgdx.png"));
	texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
	
	TextureRegion region = new TextureRegion(texture, 0, 0, 200, 200);
	
	sprite = new Sprite(region);
	sprite.setSize(1f,  sprite.getHeight() / sprite.getWidth());
	sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
	sprite.setPosition(-.5f, -.5f);

}
 
開發者ID:game-libgdx-unity,項目名稱:GDX-Engine,代碼行數:20,代碼來源:MyGdxGame.java

示例7: GozaName

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public GozaName(int goza_no) {
	// TODO Auto-generated constructor stub
	goza_name_texture = book.get_region("s"+goza_no);
	Goza_name_sprite = new Sprite(goza_name_texture);
	width = sorah_name_width ; 
	height = tab_height ;
	Goza_name_sprite.setSize(width, height);
	no = goza_no ;
	text_y_deferance=2*tab_height/3;
	x = (sorah_page_no_width+sorah_tanzel_width+ayat_widht)+sorah_tab_book_mark_width*3  ;
	y = book.sorah_scroll_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1)));
	
	no_of_surah = new TextActor(no+"",
			null,
			tab_no_width,
			TextAlign.align_cinter,tab_no_text_scale,x+sorah_name_width, text_y_deferance+y);
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:18,代碼來源:SorahTab.java

示例8: drawHealthBar

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void drawHealthBar(HealthComponent healthComp, PositionComponent pos) {
	final float healthBarHeight = Assets.enemyRedHealthbarBG.getHeight();
	final float healthBarWidth = Assets.enemyRedHealthbarBG.getWidth();
	// getting the scale ratio
	final double ratio = healthBarWidth / healthComp.maxHealth;
	Sprite spriteBg = Assets.enemyRedHealthbarBG;
	Sprite sprite = Assets.enemyGreenHealthbarBG;
	// todo center hp bar
	sprite.setPosition(pos.position.x, pos.position.y);
	spriteBg.setPosition(pos.position.x, pos.position.y);
	if(healthComp.health > 0)
		sprite.setSize((float) (ratio * healthComp.health), healthBarHeight);
	// 100 %
	if (healthComp.health <= healthComp.maxHealth)
		sprite.setColor(0, 0.75f, 0, 1f);
	// 75 %
	if (healthComp.health <= 0.75 * healthComp.maxHealth)
		sprite.setColor(Color.YELLOW);
	// 50%
	if (healthComp.health <= 0.50 * healthComp.maxHealth)
		sprite.setColor(Color.ORANGE);
	// 25%
	if (healthComp.health <= 0.25 * healthComp.maxHealth)
		sprite.setColor(Color.BROWN);
	// if enemy isn't hurt don't draw health.
	if (healthComp.health != healthComp.maxHealth) {
		_batch.begin();
		spriteBg.draw(_batch);
		sprite.draw(_batch);
		_batch.end();
	}
}
 
開發者ID:JoakimRW,項目名稱:ExamensArbeteTD,代碼行數:33,代碼來源:HealthSystem.java

示例9: MakeMadany

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public MakeMadany(int sorah_no){ 
	// TODO Auto-generated constructor stub
	goza_name_texture = book.get_region(suar_state[sorah_no-1]?"makah":"madinah");
	Goza_name_sprite = new Sprite(goza_name_texture);
	height = tab_height ;
	width = height; 
	Goza_name_sprite.setSize(width, height);
	no = sorah_no ;
	x = sorah_page_no_width+(sorah_tanzel_width-width)/2 ;
	y = book.sorah_scroll_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1)));
	text_y_deferance=2*tab_height/3;
	surah_page_no = new TextActor(""+surah_page[no-1],
			null,
			sorah_page_no_width,
			TextAlign.align_cinter, tab_no_text_scale,0,text_y_deferance+y);
	
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:18,代碼來源:SorahTab.java

示例10: createPlanet

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void createPlanet(int velDir) {
    Pixmap pixmap = generatePlanetPixmap(1024);
    Sprite planet = new Sprite(new Texture(pixmap));
    int size = MathUtils.random(100, 148);
    planet.setSize(size, size);
    planet.setPosition(CENTER_X - planet.getWidth() / 2, CENTER_Y - planet.getHeight() / 2);
    this.planet = new Planet(planet, pixmap, velDir);
    spaceObjects.add(this.planet);
}
 
開發者ID:ZKasica,項目名稱:Planet-Generator,代碼行數:10,代碼來源:Scene.java

示例11: loadPlanet

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void loadPlanet(Json json, JsonValue jsonData) {
    planet = json.readValue("planet", Planet.class, jsonData);

    Pixmap loadPixmap = new Pixmap(1024, 1024, Pixmap.Format.RGBA8888);
    int index = 0;
    for(int x = 0; x < 1024; x++) {
        for (int y = 0; y < 1024; y++) {
            int color = 0;
            switch (planet.getTextureString().charAt(index)) {
                case 'd':
                    color = Color.rgba8888(47f / 255f, 86f / 255f, 118f / 255f, 1f);
                    break;

                case 'o':
                    color = Color.rgba8888(62f / 255f, 120f / 255f, 160f / 255f, 1f);
                    break;

                case 'l':
                    color = Color.rgba8888(146f / 255f, 209f / 255f, 135f / 255f, 1f);
                    break;
            }

            index++;

            loadPixmap.setColor(color);
            loadPixmap.drawPixel(x, y);
        }
    }

    Sprite sprite = new Sprite(new Texture(loadPixmap));
    sprite.setSize(planet.getSize(), planet.getSize());
    sprite.setPosition(CENTER_X - planet.getSize() / 2, CENTER_Y - planet.getSize() / 2);
    planet = new Planet(sprite, loadPixmap, objectGenerator.getVelDir());

    spaceObjects.add(planet);
}
 
開發者ID:ZKasica,項目名稱:Planet-Generator,代碼行數:37,代碼來源:Scene.java

示例12: Pading

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public Pading(int no_of_me) {
	// TODO Auto-generated constructor stub
	bar = book.loading_texture_atlas.findRegion("loadingbar");
pading_sprite = new Sprite(bar); 
pading_sprite.setColor(0,0,0,1);
width = tab_width ;
height = tab_pading_height ;
pading_sprite.setSize(width, height);
no = no_of_me ;
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:11,代碼來源:SorahTab.java

示例13: BookMarks

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public BookMarks(int sorah_no , int type_from1_to3) {
	// TODO Auto-generated constructor stub
	bookmark_type = type_from1_to3 ;
	bookmark_texture = book.images_textures_atlas.findRegion("bookmark"+bookmark_type);
	bookmark_sprite = new Sprite(bookmark_texture) ;
	bookmark_sprite.setSize(sorah_tab_book_mark_width, tab_height);
	no = sorah_no ;
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:9,代碼來源:SorahTab.java

示例14: initBars

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void initBars() {
    bars = new ArrayList<Sprite>();
    for(int i = 0; i < NUM_BARS; i++) {
        Sprite bar = new Sprite(AssetDoctor.getSprite("color_white"));
        bar.setOrigin(0f, 0f);
        bar.setColor(Color.BLACK);
        height = DS.T_HEIGHT/(float)NUM_BARS;
        bar.setSize(DS.T_WIDTH, height);
        bar.setPosition(0, i*height);
        bars.add(bar);
    }
}
 
開發者ID:dsaves,項目名稱:Ponytron,代碼行數:13,代碼來源:IntroWipeAnimation.java

示例15: draw

import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
	// TODO Auto-generated method stub
	super.draw(batch, parentAlpha);
	if(is_me_get_focus == false){
		if(Math.pow(this.page_no-book.current_page,2)<=book.pages_range_to_load){
			page_textrue=new Texture(Gdx.files.internal("pagestray/p"+page_no+".png"));
			page_textrue.setFilter(TextureFilter.Linear,TextureFilter.Linear);
			page_sprite = new Sprite(page_textrue); 
			page_sprite.setSize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
			
			is_me_get_focus = true;
			//book.android.make_toast("page no : "+page_no+" loaded", false);
		}
	}else
	{
		
		b_a_s.setColor(255/255f,27/255f,177/255f,book.bookmark_a_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
		b_b_s.setColor(27/255f,255/255f,215/255f,book.bookmark_b_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
		b_c_s.setColor(255/255f,220/255f,27/255f,book.bookmark_c_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
		
		
		b_a_s.setPosition(b_first_x,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+ b_y);
		b_b_s.setPosition(b_first_x+b_pading_x+b_width, book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+b_y);
		b_c_s.setPosition(b_first_x+2*b_pading_x+2*b_width, book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+b_y);
	
		back_ground.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
		britness.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
		
		page_sprite.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
		page_sprite.setAlpha(book.stage_detector==Stages.menu?.3f:1);
		back_ground.setAlpha(book.them_detector ==Thems.colord?1:0);
	
		britness.setAlpha(1f-(book.light_value*.01f));
		back_ground.draw(batch);
		page_sprite.draw(batch);
		britness.draw(batch);
		b_a_s.draw(batch);
		b_b_s.draw(batch);
		b_c_s.draw(batch);
	}
	if(Math.pow(this.page_no-book.current_page,2)>book.pages_range_to_load&&is_me_get_focus){
	//	book.android.make_toast("page no : "+page_no+" unloaded", false);
		is_me_get_focus = false ;
		page_sprite = null ;
		page_textrue.dispose() ;
		
		
	}
	
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:52,代碼來源:PageSeen.java


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