存档

2011年2月 的存档

Repeater嵌套实现论坛板块界面及贴吧内容页

2011年2月20日 没有评论

首先理解实现方法,rpt可以实现从库中去出的数据,自定义布局,常见的栏目排版大致是这样:

1,栏目1

2,栏目2

3,栏目3

这是常见的rpt使用,但做论坛板块就要细分到子版块,那格式就有所不同。

1,栏目1

   1,栏目1-子栏目1

   1,栏目2-子栏目2

2,栏目2

   2,栏目1-子栏目1

   2,栏目2-子栏目2

要达到这样的效果就要使用到RPT嵌套。

大致说一下数据库设计方式,简单的设计,不说的特别复杂。首先有普通栏目的一些信息,ID字段,还有是否子栏目的字段,父级栏目

的ID标识等等。根据自己设计情况定夺,设计好之后就开始大致布局一下上面的板块;

Repeater嵌套实现论坛板块界面及贴吧内容页

我设计的界面大致图。

代码如下:

Repeater嵌套实现论坛板块界面及贴吧内容页Repeater嵌套实现论坛板块界面及贴吧内容页View Code

<div class="Star_Btop">
<div class="Star_bbsFrame">
<div class="Star_bbs_Top">社区公告:</div>
<asp:Repeater ID="RepeaterForFristList" runat="server"
onitemdatabound
="RepeaterForFristList_ItemDataBound" >
<ItemTemplate>
<div class="Star_bbs_One">
<a><%# DataBinder.Eval(Container.DataItem, "StarTitle")%></a>
</div>
<asp:Repeater ID="RepeaterForSedList" runat="server">
<ItemTemplate>
<div class="Star_B_O_BD">
<div class="Star_B_O_one">
<div class="Star_B_O_ImgF">
<a href="/star_list_<%#Eval("ID") %>"><img src="<%# DataBinder.Eval(Container.DataItem, "StarImg")%>" alt="<%# DataBinder.Eval(Container.DataItem, "StarTitle")%>" /></a>
</div>
<div class="Star_B_O_TextF">
<div class="Star_B_O_T_Title"><a href="/star_list_<%#Eval("ID") %>"><%# DataBinder.Eval(Container.DataItem, "StarTitle")%></a>(今日:<span style="color:#FF6600; font-weight:normal;"><%#pa.GetStarIDReturnTodayBBs(Convert.ToInt32(Eval("ID")))%></span>)</div>
<div class="Star_B_O_T_text"><%# DataBinder.Eval(Container.DataItem, "Dis")%></div>
</div>
</div>
<div class="Star_B_O_HF"><span><%#pa.GetStarIDReturnMainBBs(Convert.ToInt32(Eval("ID")))%></span>&nbsp;/&nbsp;<%#pa.GetStarIDReturnAllBBs(Convert.ToInt32(Eval("ID")))%></div>
<div class="Star_B_O_T_LastHF">
<div class="Star_B_O_T_BBSTitle"><a href="/star_<%#pa.GetStarIDReturnlastbbsinfo(Convert.ToInt32(Eval("ID"))).ID%>"><%#pa.GetStarIDReturnlastbbsinfo(Convert.ToInt32(Eval("ID"))).BBsTitle%></a></div>
<div class="Star_B_O_T_BBSArter">作者:<%#pa.GetName(Convert.ToInt32(pa.GetStarIDReturnlastbbsinfo(Convert.ToInt32(Eval("ID"))).MyNumber))%>&nbsp;-<%#pa.DateDiff(Convert.ToDateTime(pa.GetStarIDReturnlastbbsinfo(Convert.ToInt32(Eval("ID"))).CreateTime))%></div>
</div>

</div>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</div>

 在代码中的RPT控件RepeaterForFristList(顶级板块)中再次使用了一个RPT控件RepeaterForSedList,这样就达到了我们想要

的基本效果,然后把论坛板块的基本字段信息填写好,就可以了。

具体绑定方法:

首先将表层的RPT绑定,大家应该都会;

RepeaterForFristList.DataSource = starmainobj.GetListInfo(10, "", "Starcolumn=1 and Recommend=0", " Starorder asc");
RepeaterForFristList.DataBind();

然后绑定里层子RPT绑定,首先要从表层获取到一些表层的基本字段,比如ID项,这就是为什么要在数据库设计时要多建立一个父级

ID字段,来区分我的子RPT绑定的是哪个板块下面的栏目。

Star_Main starmainobj = new Star_Main();
protected void RepeaterForFristList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rptProduct
= (Repeater)e.Item.FindControl("RepeaterForSedList");
//找到分类Repeater关联的数据项
DataRowView rowv = (DataRowView)e.Item.DataItem;
//提取分类ID
int CategorieId = Convert.ToInt32(rowv["ID"]);
//根据分类ID查询该分类下的板块,并绑定板块Repeater
rptProduct.DataSource = starmainobj.GetListInfo(10, "", "Starcolumn=" + CategorieId + " and Recommend=0", " Starorder asc");
rptProduct.DataBind();
}
}

Repeater rptProduct = (Repeater)e.Item.FindControl(RepeaterForSedList);
自定义 RPT控件 绑定到 RepeaterForSedList 中,因为此时的的子集RPT是一个集合;   

上面的绑定代码中,int CategorieId = Convert.ToInt32(rowv[ID]);获取到父级栏目字段ID后,进行绑定;

运行一下看效果:

Repeater嵌套实现论坛板块界面及贴吧内容页

论坛中我顺便也在后台做了一个简单的管理的功能,这样方便首页显示调用:

Repeater嵌套实现论坛板块界面及贴吧内容页

基本达到了仿一些社区版块的设计方式,还可以利用这种方法做贴吧回复,文章回复的列表信息;

Repeater嵌套实现论坛板块界面及贴吧内容页

这种也就是RPT嵌套做出来的嘛,效果还是相当不错的噢!

希望可以和大家更多交流一下。

分类: 未分类 标签:

What is a good game engine that uses Lua? [closed]

2011年2月19日 没有评论

I know Love2D and Corona SDK (for mobile devices). Is there any other game engines that use Lua you recommend?

World of Warcraft’s engine seems all right, and it uses Lua. :)

Heroes of Might and Magic V used modified Silent Storm engine. I think you can find many good engines listed in wikipedia: Lua-scriptable game engines

List of game engines that use lua:

2D

  • Agen (Lua; Windows)
  • Blitwizard (Lua; Windows, Linux, Mac)
  • Cocos2d-x (C++/Lua/JS; Windows, Linux, Mac; iOS/Android/BlackBerry)
  • Corona (Lua; Windows, Mac; iOS/Android)
  • EGSL (Pascal/Lua; Windows, Linux, Mac, Haiku)
  • Grail Adventure Game Engine (C++/Lua; Windows, Linux, MacOS X (SDL))
  • LÖVE (Lua; Windows, Linux, Mac)
  • MOAI (C++/Lua; Windows, Linux, Mac; iOS, Android; Google Chrome (Native Client))

2.5D

3D

A few more:

There’s our IDE / engine called Codea.

The runtime is iOS only, but it’s open source. The development environment is iPad only at the moment.

I can second the previous posters enthusiasm for the Gideros Lua game engine, whilst focusing currently on Mobile (iOS and Android – Windows phone 8 is in the works), desktop support for Mac, PC (possibly Linux) is also planned for the not too distant future.

Google for “Gideros Mobile”

cocos2d convertToWorldSpace

2011年2月18日 没有评论

I’m not sure convertToWorldSpace works.

  • I have spriteA which is the parent.

  • I set it to position 40,40 for example and add it to the scene.

  • I have a second spriteB which I set at position 80,80.

  • I add spriteB to spriteA.

  • I print out the position of spriteB: 80,80.

  • I then print [self convertToWorldSpace:spriteB.position]. And, I still get 80,80.
    Shouldn’t spriteB position be different here?

In your case if you want know the position of your spriteB in the current world you must call the “convertToWorldSpace” methods from its parent (the spriteA) :

[spriteA convertToWorldSpace:spriteB.position];

The “convertToWorldSpace:” method applies the node’s transformation to the given position. You should always call this methods from the parent’s sprite.

ConvertToWorldSpace takes LOCAL node coordinates, and converts them to the world coordinates.
ConvertToNodeSpace takes WORLD coordinates, converts them to the calling node’s coordinates.
(If so call [nodeA convertToWorldSpace:ccp(10,10)], it assumes that the (10,10) position is for a child of nodeA)

Basically, To get the world position of any node (in cocos2d 3 or later) use this code:

CGPoint worldPosition=[node.parent convertToWorldSpace:node.positionInPoints];

I personally made a function so I can use this over and over (add it to the top of any .m/.h file and you will see it)

static inline CGPoint
worldPosOfNode(CCNode *node){
    return [node.parent convertToWorldSpace:node.positionInPoints];
}

And I use it like this: (myNode can be any cocos2d sprite, label or whatever)

CGPoint worldPosition=worldPosOfNode(myNode);
分类: stackoverflow精选, unity3d 标签: