本文整理汇总了C#中cocos2d.CCSprite.setTextureRect方法的典型用法代码示例。如果您正苦于以下问题:C# CCSprite.setTextureRect方法的具体用法?C# CCSprite.setTextureRect怎么用?C# CCSprite.setTextureRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d.CCSprite
的用法示例。
在下文中一共展示了CCSprite.setTextureRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpriteNilTexture
public SpriteNilTexture()
{
CCSize s = CCDirector.sharedDirector().getWinSize();
CCSprite sprite = null;
// TEST: If no texture is given, then Opacity + Color should work.
sprite = new CCSprite();
sprite.init();
sprite.setTextureRect(new CCRect(0, 0, 300, 300));
sprite.Color = new ccColor3B(Color.Red);
sprite.Opacity = 128;
sprite.position = (new CCPoint(3 * s.width / 4, s.height / 2));
addChild(sprite, 100);
sprite = new CCSprite();
sprite.init();
sprite.setTextureRect(new CCRect(0, 0, 300, 300));
sprite.Color = new ccColor3B(Color.Blue);
sprite.Opacity = 128 ;
sprite.position = (new CCPoint(1 * s.width / 4, s.height / 2));
addChild(sprite, 100);
}
示例2: CameraCenterTest
public CameraCenterTest()
{
CCSize s = CCDirector.sharedDirector().getWinSize();
CCSprite sprite;
CCOrbitCamera orbit;
// LEFT-TOP
sprite = new CCSprite();//::node();
sprite.init();
addChild(sprite, 0);
sprite.position = (new CCPoint(s.width / 5 * 1, s.height / 5 * 1));
sprite.Color = (new ccColor3B(Color.Red));
sprite.setTextureRect(new CCRect(0, 0, 120, 50));
orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0);
//sprite.runAction(CCRepeatForever.actionWithAction( orbit));
// [sprite setAnchorPoint: CCPointMake(0,1));
// LEFT-BOTTOM
sprite = new CCSprite();//::node();
sprite.init();
addChild(sprite, 0, 40);
sprite.position = (new CCPoint(s.width / 5 * 1, s.height / 5 * 4));
sprite.Color = new ccColor3B(Color.Blue);
sprite.setTextureRect( new CCRect(0, 0, 120, 50));
orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0);
//sprite.runAction(CCRepeatForever.actionWithAction( orbit ));
// [sprite setAnchorPoint: CCPointMake(0,0));
// RIGHT-TOP
sprite = new CCSprite();//::node();
sprite.init();
addChild(sprite, 0);
sprite.position = (new CCPoint(s.width / 5 * 4, s.height / 5 * 1));
sprite.Color = new ccColor3B(Color.Yellow);
sprite.setTextureRect (new CCRect(0, 0, 120, 50));
orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0);
//sprite.runAction(CCRepeatForever.actionWithAction(orbit));
// [sprite setAnchorPoint: CCPointMake(1,1));
// RIGHT-BOTTOM
sprite = new CCSprite();//::node();
sprite.init();
addChild(sprite, 0, 40);
sprite.position = (new CCPoint(s.width / 5 * 4, s.height / 5 * 4));
sprite.Color = new ccColor3B(Color.Green);
sprite.setTextureRect(new CCRect(0, 0, 120, 50));
orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0);
// sprite.runAction(CCRepeatForever.actionWithAction(orbit));
// [sprite setAnchorPoint: CCPointMake(1,0));
// CENTER
sprite = new CCSprite();
sprite.init();
addChild(sprite, 0, 40);
sprite.position = (new CCPoint(s.width / 2, s.height / 2));
sprite.Color = new ccColor3B(Color.White);
sprite.setTextureRect(new CCRect(0, 0, 120, 50));
orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0);
// sprite.runAction(CCRepeatForever.actionWithAction(orbit));
// [sprite setAnchorPoint: CCPointMake(0.5f, 0.5f));
}