当前位置: 首页>>代码示例>>C#>>正文


C# CCSprite.setTextureRect方法代码示例

本文整理汇总了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);
        }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:24,代码来源:SpriteNilTexture.cs

示例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));
        }
开发者ID:Ratel13,项目名称:cocos2d-x-for-xna,代码行数:66,代码来源:CameraCenterTest.cs


注:本文中的cocos2d.CCSprite.setTextureRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。