从纹理图集创建精灵

时间:2016-12-01 10:33:28

标签: libgdx sprite texture-atlas

在我的libGdx项目中,我使用createSprite()从纹理图集创建了一个精灵。 我想将sprite实现为旋转。 我怎么能这样做?这是我的代码:

 reelSprite = atlas.createSprite("reel"); 

在render()中:

for (Wall lWalls : leftWalls){
        reelSprite.setOrigin(lWalls.getX(), lWalls.getY());
        reelSprite.setRotation(180);

    batch.draw(reelSprite, lWalls.getX(), lWalls.getY());
    }

此代码无效。请告诉我我做错了什么。

3 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

(odoo-env) Marcios-MacBook-Pro:odoo mars$ brew cleanup
(odoo-env) Marcios-MacBook-Pro:odoo mars$ brew link node
Linking /usr/local/Cellar/node/7.2.0... 
Error: Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
  rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
  brew link --overwrite node
To list all files that would be deleted:
  brew link --overwrite --dry-run node
(odoo-env) Marcios-MacBook-Pro:odoo mars$ brew cleanup
(odoo-env) Marcios-MacBook-Pro:odoo mars$ brew link node
Linking /usr/local/Cellar/node/7.2.0... 
Error: Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
  rm '/usr/local/bin/node'

To force the link and overwrite all conflicting files:
  brew link --overwrite node

To list all files that would be deleted:
  brew link --overwrite --dry-run node

答案 2 :(得分:0)

我改变了这样的代码......

for (Wall lWalls : leftWalls){
        reelSprite1.setPosition(lWalls.getX(), lWalls.getY());
        reelSprite1.setOrigin(reelSprite1.getWidth()/2,reelSprite1.getHeight()/2);
        reelSprite1.setRotation(180);
        reelSprite1.draw(batch);

然后它奏效了。