本文整理汇总了C#中Sprite.addEventListner方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.addEventListner方法的具体用法?C# Sprite.addEventListner怎么用?C# Sprite.addEventListner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.addEventListner方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: buildPlayable
void buildPlayable()
{
XmlNodeList areas = _node.SelectNodes("area");
for (int i=0; i<areas.Count; i++){
Texture2D tex = Resources.Load("page/blank", typeof(Texture2D)) as Texture2D;
Sprite sprite = new Sprite(tex);
sprite.x = float.Parse(areas[i].Attributes["x"].Value);
sprite.y = float.Parse(areas[i].Attributes["y"].Value);
sprite.width = float.Parse(areas[i].Attributes["width"].Value);
sprite.height = float.Parse(areas[i].Attributes["height"].Value);
sprite.tag = areas[i].Attributes["videoSrc"].Value;
addChild(sprite);
sprite.addEventListner(MouseEvent.MOUSE_DOWN, new EventDispatcher.CallBack(playableClicked));
}
}
示例3: buildGallary
protected void buildGallary()
{
XmlNodeList imgs = _node.SelectNodes("img");
_gallaryItems = new SelectableItem[imgs.Count];
for (int i=0; i<Math.Min(2, imgs.Count); i++){
PageType subType = PageType.Single;
if (imgs[i].Attributes["type"] != null)
subType = (PageType)Enum.Parse(typeof(PageType), imgs[i].Attributes["type"].Value);
if (subType != PageType.Single){
_gallaryItems[i] = new InteractImagePage(imgs[i], _menuElement);
}
else{
_gallaryItems[i] = new SelectableItemEx(imgs[i], _menuElement); //,1024f,668f);
}
_gallaryItems[i].x = (i==0) ? 0 : _screenWidth;
_gallaryItems[i].id = "gallaryItem-" + i;
addGallaryItem(_gallaryItems[i]);
}
if (imgs.Count > 0){
Texture2D arrow = Resources.Load("mainMenu/component/arrow-left", typeof(Texture2D)) as Texture2D;
_left = new SelectableItem(arrow);
_left.alpha = 0;
_left.x = 0;
_left.y = (668-arrow.height)/2f;
_left.id = "gallary-left-arrow";
_left.addEventListner(MouseEvent.MOUSE_DOWN, new EventDispatcher.CallBack(leftArrowClicked));
base.addChild(_left);
arrow = Resources.Load("mainMenu/component/arrow-right", typeof(Texture2D)) as Texture2D;
_right = new SelectableItem(arrow);
_right.alpha = 1f;
_right.x = _screenWidth-arrow.width;
_right.y = (668-arrow.height)/2f;
_right.id = "gallary-right-arrow";
_right.addEventListner(MouseEvent.MOUSE_DOWN, new EventDispatcher.CallBack(rightArrowClicked));
base.addChild(_right);
}
}
示例4: buildZoomable
protected void buildZoomable()
{
XmlNodeList imgs = _node.SelectNodes("img");
_clipPos = new Vector2[imgs.Count];
for (int i=0; i<_clipPos.Length; i++){
float x = float.Parse(imgs[i].Attributes["x"].Value);
float y = float.Parse(imgs[i].Attributes["y"].Value);
_clipPos[i] = new Vector2(x, y);
InteractImageClip clip = new InteractImageClip(_menuElement.GetTextureById(imgs[i].Attributes["src"].Value));
addZoomableItem(clip);
float w = float.Parse(imgs[i].Attributes["width"].Value);
float h = float.Parse(imgs[i].Attributes["height"].Value);
clip.x = x;
clip.y = y;
clip.width = w;
clip.height = h;
clip.tag = w+","+h;
if (imgs[i].Attributes["type"] != null){
ZoomableContentType type = (ZoomableContentType)Enum.Parse(typeof(ZoomableContentType), imgs[i].Attributes["type"].Value);
clip.type = type;
if (imgs[i].Attributes["videoSrc"] != null){
clip.videoSrc = imgs[i].Attributes["videoSrc"].Value;
}
}
}
XmlNodeList vids = _node.SelectNodes("video");
for (int i=0; i<vids.Count; i++){
Texture2D tex = Resources.Load("page/blank", typeof(Texture2D)) as Texture2D;
Sprite sprite = new Sprite(tex);
sprite.x = float.Parse(vids[i].Attributes["x"].Value);
sprite.y = float.Parse(vids[i].Attributes["y"].Value);
sprite.width = float.Parse(vids[i].Attributes["width"].Value);
sprite.height = float.Parse(vids[i].Attributes["height"].Value);
sprite.tag = vids[i].Attributes["src"].Value;
addChild(sprite);
sprite.addEventListner(MouseEvent.MOUSE_DOWN, new EventDispatcher.CallBack(playableClicked));
}
}