2013-02-10 1 views
4

나는 LibGDX에 Sprite을 그리려고합니다. 내가 대신 Sprite();을 사용하고 setTexture 및/또는 setRegion, 어떤 그림이 그려지지 않습니다 사용하려고하면 나는빈 생성자에서 LibGDX 스프라이트 그리는 방법

Sprite sprite = new Sprite(new Texture(Gdx.files.internal("path"))); 

등 사용할 수있는 질감을 지정하는 생성자를 사용하는 경우 그것을 할 수 있지만. API는 무엇이든 그려지기 전에 "질감, 질감 영역, 범위 및 색상"을 설정해야한다고 말합니다. 아무것도 그려지지 않았지만 setTexture, setRegionsetColor으로 전화를 걸었습니다.

주요 질문 : 기본 Sprite() 생성자를 사용하는 경우 이후에 화면에 그려야 할 사항은 무엇입니까 (SpriteBatch)? 나는 code'll 가정 것

답변

3

Sprite(Texture) ctor does과 매우 동일한 단계를 수행해야합니다

public Sprite (Texture texture) { 
    this(texture, 0, 0, texture.getWidth(), texture.getHeight()); 
} 

public Sprite (Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) { 
    if (texture == null) throw new IllegalArgumentException("texture cannot be null."); 
    this.texture = texture; 
    setRegion(srcX, srcY, srcWidth, srcHeight); 
    setColor(1, 1, 1, 1); 
    setSize(Math.abs(srcWidth), Math.abs(srcHeight)); 
    setOrigin(width/2, height/2); 
} 

이 모든 공용 방법이 있습니다.