本文整理汇总了C#中Sprite.addChild方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.addChild方法的具体用法?C# Sprite.addChild怎么用?C# Sprite.addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.addChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MaskScene
public MaskScene()
{
mContents = new Sprite();
addChild(mContents);
var stageWidth = 640f;
var stageHeight = 960f;
var touchQuad = new Quad(stageWidth, stageHeight, Color.black);
touchQuad.alpha = 0.01f; // used to get touch events
addChildAt(touchQuad, 0);
var image = new Image(Game.assets.getTexture("flight_00"));
image.x = (stageWidth * 0.5f) - (image.width * 0.75f);
image.y = 80f;
mContents.addChild(image);
var scissorText = new BitmapTextField();
scissorText.width = 512f;
scissorText.height = 256f;
scissorText.multiline = true;
scissorText.textFormat = Game.textFormat;
scissorText.text = "Move the mouse (or a finger) over the screen to move the clipping rectangle.";
scissorText.x = (stageWidth - scissorText.width) * 0.5f;
scissorText.y = 480f;
mContents.addChild(scissorText);
var maskText = new BitmapTextField();
maskText.width = 512f;
maskText.height = 256f;
maskText.multiline = true;
maskText.textFormat = Game.textFormat;
maskText.text = "Currently, Starling supports only stage-aligned clipping; more complex masks " +
"will be supported in future versions.";
maskText.x = scissorText.x;
maskText.y = 580;
mContents.addChild(maskText);
var scissorRect = new Rect(0f, 0f, 300f, 300f);
scissorRect.x = (stageWidth - scissorRect.width) / 2f;
scissorRect.y = (stageHeight - scissorRect.height) / 2f + 5f;
mContents.clipRect = scissorRect;
mClipQuad = new Quad(scissorRect.width, scissorRect.height, 0xff0000.hexToColor());
mClipQuad.x = scissorRect.x;
mClipQuad.y = scissorRect.y;
mClipQuad.alpha = 0.1f;
addChild(mClipQuad);
addEventListener(MouseEvent.MOUSE_MOVE, onTouch);
}
示例2: Start
void Start()
{
Texture2D texture = Resources.Load("testimg3",typeof(Texture2D)) as Texture2D;
s = new Sprite(texture);
s.id = "s";
Stage.instance.addChild(s);
s.x = 300;
s.y = 300;
s1 = new Sprite(texture);
s1.id = "s1";
s.addChild(s1);
s1.scaleX = .5f;
s1.x = 150;
s1.y = 50;
//s1.width = 50;
//s1.height = 50;
Debug.Log(s1.width+"/"+s1.height);
s2 = new SelectableItem(texture);
s2.id = "s2";
s1.addChild(s2);
s2.x = 250;
s2.y = 100;
s3 = new Sprite(texture);
s2.addChild(s3);
s3.scaleX = .3f;
s3.scaleY = .3f;
s.addEventListner(MouseEvent.MOUSE_DOWN,new EventDispatcher.CallBack(clickHandler));
s.addEventListner(GuiEvent.ENTER_FRAME,new EventDispatcher.CallBack(enterFrameHandler));
}
示例3: Game
public Game()
{
// http://forum.starling-framework.org/topic/framerate-drops-a-lot
// http://forum.starling-framework.org/topic/30-fps-in-chrome-but-60-fps-in-internet-explorer-huh
// http://forum.starling-framework.org/topic/frame-rate-oddities
// http://forums.tigsource.com/index.php?topic=23953.0
// IE 59
// FF 56
// Chrome, 62? after a restart of chrome!
var info = new TextField(100, 400, "Welcome to StarlingRenderTextureExperiment!");
addChild(info);
var maxframe = new Stopwatch();
var maxframe_elapsed = 0.0;
var xinfo = new TextField(400, 300, "Welcome to StarlingRenderTextureExperiment!");
var xsw = new Stopwatch();
xsw.Start();
var content_rot = new Sprite();
var texture0 = Texture.fromBitmap(new ActionScript.Images.jsc());
////var cc = 128; // 10 FPS
//var cc = 64; // 33 FPS, 44 FPS
var cc = 128; //59
var bytes = 0;
var texsize = 512;
#region new_tile
Func<Image> new_tile = delegate
{
//var rtex = new RenderTexture(2048, 2048, true, 1);
var rtex = new RenderTexture(texsize, texsize, true, 1);
var rimg = new Image(rtex);
var img0 = new Image(texture0);
img0.scaleX = 0.3;
img0.scaleY = 0.3;
Action updatetexture = delegate
{
rtex.drawBundled(
new Action(
delegate
{
for (int iy = 0; iy <= cc; iy++)
for (int ix = 0; ix <= cc; ix++)
{
img0.x = ix * 64 * img0.scaleX;
img0.y = iy * 64 * img0.scaleY;
if (img0.x < rtex.width)
if (img0.y < rtex.height)
rtex.draw(img0);
}
}
).ToFunction()
);
};
updatetexture();
ApplicationSprite.__stage.stage3Ds[0].context3DCreate +=
delegate
{
rtex = new RenderTexture(texsize, texsize, true, 1);
updatetexture();
rimg.texture = rtex;
};
bytes += texsize * texsize * 6;
return rimg;
};
#endregion
var memory_for_text = new RenderTexture(1024, 1024, true, 1);
// Error: Error #3691: Resource limit for this resource type exceeded.
//at flash.display3D::Context3D/createTexture()
var count = 0;
for (int iy = -1; iy <= 4; iy++)
//.........这里部分代码省略.........
示例4: Game
public Game()
{
// http://forum.starling-framework.org/topic/framerate-drops-a-lot
// http://forum.starling-framework.org/topic/30-fps-in-chrome-but-60-fps-in-internet-explorer-huh
// http://forum.starling-framework.org/topic/frame-rate-oddities
// http://forums.tigsource.com/index.php?topic=23953.0
// IE 59
// FF 56
// Chrome, 62? after a restart of chrome!
var info = new TextField(100, 100, "Welcome to StarlingTextureScrollExperiment!");
addChild(info);
var maxframe = new Stopwatch();
var maxframe_elapsed = 0.0;
#region fps
var sw = new Stopwatch();
sw.Start();
var ii = 0;
maxframe.Start();
ApplicationSprite.__stage.enterFrame +=
delegate
{
maxframe.Stop();
// System.TimeSpan for Boolean op_GreaterThan(System.TimeSpan, System.TimeSpan) used at
//FlashHeatZeeker.ApplicationSprite+<>c__DisplayClass11.<.ctor>b__d at offset 001e.
// TypeError: Error #1009: Cannot access a property or method of a null object reference.
//at FlashHeatZeeker::ApplicationSprite___c__DisplayClass11/__ctor_b__d_100663322()[U:\web\FlashHeatZeeker\ApplicationSprite___c__DisplayClass11.as:141]
if (maxframe.Elapsed.TotalMilliseconds > maxframe_elapsed)
maxframe_elapsed = maxframe.Elapsed.TotalMilliseconds;
if (sw.ElapsedMilliseconds < 1000)
{
ii++;
maxframe.Restart();
return;
}
info.text = new { fps = ii, maxframe_elapsed }.ToString();
//if (fps != null)
// fps("" + ii);
ii = 0;
maxframe_elapsed = 0;
sw.Restart();
};
#endregion
var xinfo = new TextField(400, 300, "Welcome to StarlingTextureScrollExperiment!");
var xsw = new Stopwatch();
xsw.Start();
var content_rot = new Sprite();
//var texture0 = Texture.fromBitmap(new ActionScript.Images.jsc128());
var texture0 = Texture.fromBitmap(
new ActionScript.Images.jsc128(), repeat: true
);
var img0 = new Image(texture0);
// http://forum.starling-framework.org/topic/best-way-to-do-a-scroll-background
var hRatio = 1.0;
var vRatio = 1.0;
Action<Image, double, double> setOffset = (image, xx, yy) =>
{
yy = ((yy / image.height % 1) + 1);
xx = ((xx / image.width % 1) + 1);
image.setTexCoords(0, new Point(xx, yy));
image.setTexCoords(1, new Point(xx + hRatio, yy));
image.setTexCoords(2, new Point(xx, yy + vRatio));
image.setTexCoords(3, new Point(xx + hRatio, yy + vRatio));
};
// wtf?
// https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201405/20140504
///** Indicates if the texture should repeat like a wallpaper or stretch the outermost pixels.
// * Note: this only works in textures with sidelengths that are powers of two and
// * that are not loaded from a texture atlas (i.e. no subtextures). @default false */
//public function get repeat():Boolean { return false; }
// X:\opensource\github\Starling-Framework\starling\src\starling\textures\ConcreteTexture.as
//texture0.repeat = true;
//.........这里部分代码省略.........
示例5: Game
public Game()
{
// http://forum.starling-framework.org/topic/framerate-drops-a-lot
// http://forum.starling-framework.org/topic/30-fps-in-chrome-but-60-fps-in-internet-explorer-huh
// http://forum.starling-framework.org/topic/frame-rate-oddities
// http://forums.tigsource.com/index.php?topic=23953.0
// IE 59
// FF 56
// Chrome, 62? after a restart of chrome!
var info = new TextField(100, 100, "Welcome to StarlingRotationExperiment!");
addChild(info);
var maxframe = new Stopwatch();
var maxframe_elapsed = 0.0;
// jsc analyzer, suggest net stats instead?
#region fps
var sw = new Stopwatch();
sw.Start();
var ii = 0;
var content_rot = new Sprite();
var xsw = new Stopwatch();
xsw.Start();
maxframe.Start();
ApplicationSprite.__stage.enterFrame +=
delegate
{
maxframe.Stop();
// System.TimeSpan for Boolean op_GreaterThan(System.TimeSpan, System.TimeSpan) used at
//FlashHeatZeeker.ApplicationSprite+<>c__DisplayClass11.<.ctor>b__d at offset 001e.
// TypeError: Error #1009: Cannot access a property or method of a null object reference.
//at FlashHeatZeeker::ApplicationSprite___c__DisplayClass11/__ctor_b__d_100663322()[U:\web\FlashHeatZeeker\ApplicationSprite___c__DisplayClass11.as:141]
if (maxframe.Elapsed.TotalMilliseconds > maxframe_elapsed)
maxframe_elapsed = maxframe.Elapsed.TotalMilliseconds;
if (sw.ElapsedMilliseconds < 1000)
{
ii++;
maxframe.Restart();
return;
}
//content_rot.rotation += 0.0001 * xsw.ElapsedMilliseconds;
// Nan?
info.text = new
{
fps = ii,
maxframe_elapsed,
sw = sw.ElapsedMilliseconds,
// why the duck is it Nan?
xsw = xsw.ElapsedMilliseconds,
content_rot.rotation
}.ToString();
//if (fps != null)
// fps("" + ii);
ii = 0;
maxframe_elapsed = 0;
sw.Restart();
};
#endregion
var xinfo = new TextField(400, 300, "Welcome to StarlingRotationExperiment!");
var texture0 = Texture.fromBitmap(new ActionScript.Images.jsc());
content_rot.rotation = 0.2;
//var cc = 128; // 10 FPS
var cc = 64; // 33 FPS
// fps 42
for (int iy = -cc; iy <= cc; iy++)
for (int ix = -cc; ix <= cc; ix++)
{
var img0 = new Image(texture0);
//.........这里部分代码省略.........