mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-04 10:32:39 +08:00
Merge pull request #262 from natural-law/issue3831
Add interface for set the tiles opacity of TiledLayer.
This commit is contained in:
@@ -204,6 +204,18 @@ void TMXLayer::setupTiles()
|
||||
}
|
||||
}
|
||||
|
||||
void TMXLayer::setTileOpacity(unsigned char opacity) {
|
||||
_opacity = opacity;
|
||||
for (int i = 0; i < _layerSize.width; i++) {
|
||||
for (int j = 0; j < _layerSize.height; j++) {
|
||||
Sprite* theTile = getTileAt(Vec2(i, j));
|
||||
if (theTile) {
|
||||
theTile->setOpacity(_opacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TMXLayer - Properties
|
||||
Value TMXLayer::getProperty(const std::string& propertyName) const
|
||||
{
|
||||
|
||||
@@ -278,6 +278,13 @@ public:
|
||||
inline void setProperties(const ValueMap& properties) {
|
||||
_properties = properties;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the opacity of all tiles
|
||||
* @param opacity The new opacity value
|
||||
*/
|
||||
void setTileOpacity(unsigned char opacity);
|
||||
|
||||
//
|
||||
// Override
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user