在我的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());
}
此代码无效。请告诉我我做错了什么。
答案 0 :(得分:0)
在绘制精灵之前应该使用setRotation:
甚至在设定旋转点之前:
答案 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);
然后它奏效了。