作了两个dialog,想设置第二个透明些,即从第二个dialog上能看到其下面的第一个dialog的内容,找到一个设置,试了一下不错,方法如下:
WindowManager.LayoutParams lp=dialog.getWindow().getAttributes();
lp.alpha=1.0f;
dialog.getWindow().setAttributes(lp);
alpha在0.0f到1.0f之间。1.0完全不透明,0.0f完全透明
---------------------------------------
所谓的activity中设置透明都值的是activity的主题变成了dialog,那么跳转到这个activity的时候,出现的是对话框的形式了。这样的话,同样的也使用于上面的几个方法,至少对象名换成了this,
见代码
AndroidManifest.xml 配置activity的主题是dialog样式,这个大家都会
activity的代码
import com.hzilearning.dict.activity.R;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.TextView;
/**
* 按M图片跳出来的一个选择框
*
* @author endual
*
*/
public class JumpMenuActivity extends Activity {
private TextView tv_jumpmenu_newword;
private TextView tv_jumpmenu_important;
private TextView tv_jumpmenu_mastered;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.jumpmenu);
this.setTitle(null) ;
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.alpha=0.8f;
getWindow().setAttributes(lp);
tv_jumpmenu_newword = (TextView) this
.findViewById(R.id.tv_jumpmenu_newword);
tv_jumpmenu_important = (TextView) this
.findViewById(R.id.tv_jumpmenu_important);
tv_jumpmenu_mastered = (TextView) this
.findViewById(R.id.tv_jumpmenu_mastered);
this.tv_jumpmenu_newword.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(JumpMenuActivity.this,
LearnWordListTabActivity.class);
startActivity(intent);
}
});
。。。。。。
。。。。。。
AppDelegate中的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//self.nav = [[[UINavigationController alloc ] initWithRootViewController:viewController ] autorelease ];
//设置标签栏
UIViewController *viewCon1, *viewCon2, *viewCon3, *viewCon4, *viewCon5;
viewCon1 = [[NRPTViewController alloc] init];
viewCon2 = [[NRPTViewController alloc] init];
viewCon3 = [[NRPTViewController alloc] init];
viewCon4 = [[NRPTViewController alloc] init];
viewCon5 = [[NRPTViewController alloc] init];
self.tab = [[[UITabBarController alloc] init] autorelease];
//设置5个nav
UINavigationController *nav1, *nav2, *nav3, *nav4, *nav5;
nav1 = [[[UINavigationController alloc] initWithRootViewController:viewCon1] autorelease];
nav2 = [[[UINavigationController alloc] initWithRootViewController:viewCon2] autorelease];
nav3 = [[[UINavigationController alloc] initWithRootViewController:viewCon3] autorelease];
nav4 = [[[UINavigationController alloc] initWithRootViewController:viewCon4] autorelease];
nav5 = [[[UINavigationController alloc] initWithRootViewController:viewCon5] autorelease];
self.tab.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4,nav5,nil];
//NSArray *arr = [NSArray arrayWithObjects:self.nav,nil];
[window addSubview:self.tab.view];
[window makeKeyAndVisible];
return YES;
}
在每个具体的视图中进行UITabBarItem和navigation的标题设置
- (id)init{
if ([super init] != nil) {
self.title = @"首页";
UIImage *img = [UIImage imageNamed:@"bag_2.png"];
UITabBarItem *tabItem = [[UITabBarItem alloc] initWithTitle:@"主页"
image:img
tag:0];
self.tabBarItem = tabItem;
[tabItem release];
}
return self;
}
应用博客:http://blog.sina.com.cn/s/blog_6a2061a20100n0or.html
碰撞筛选就是一个防止某些形状发生碰撞的系统。按照具体需求设置哪些物体跟那些物体发生碰撞,跟哪些物体不发生碰撞。
Box2D通过种群跟组索引支持碰撞筛选。
组索引比较简单,设置其shapeDef的groupIndex值即可,例如boxDef.filter.groupIndex = 1。
通过groupIndex值的正负来确定同一个组的所有形状总是发生碰撞(正)或永远不发生碰撞(负),需要特别注意的是两个不同的付索引是依然会发生碰撞的,例如一个圆的GroupIndex值为-1,一个矩形GroupIndex值为-2。因为不同组索引之间是按照种群跟掩码来筛选的,也就是讲,组索引是有着更高的优选权的。
Box2D支持16个种群,因此我们可以指定任何一个形状属于哪个种群,同时也可以指定这一形状和哪些其它的种群发生碰撞。这一过程就是通过设置其shapeDef的categoryBits值与maskBits值完成的。
categoryBits用于定义自己所属的碰撞种类,maskBits则是指定碰撞种类。
举个例子讲,如果body1的boxDef.filter.categoryBits = 0x0002,body2的boxDef.filter.categoryBits = 0x0004,则如果另外一个body想与他们两个都发生碰撞,则其boxDef.filter.maskBits = 0x0006;简单讲,一个body要与其它种群的body发生碰撞,则其maskBits值应该为其它种群的body的categoryBits之和。
但是同时也不是那么简单,如果三个body的categoryBits分别为0x0001,0x0002,0x0003,那另外一个body的 maskBits值如果是0x0003的话,那它是跟categoryBits值为0x0001和0x0002的两个body碰撞呢,还是单独只跟 categoryBits值0x0003的body发生碰撞呢,亦或是跟三个body都发生碰撞呢?
一个游戏中的种群一般有多少种呢?
现在我们就做一个测试,具体要求:四个刚体。
矩形:只跟自身,圆形,三角形发生碰撞。
圆形:只跟自身,矩形,五边形发生碰撞。
三角形:只跟自身,矩形发生碰撞。
五边形:只跟自身,圆形碰撞。
categoryBits值:矩形[0x0001],圆形[0x0002],三角形[0x0003],五边形[0x0004]。
maskBits值:矩形[1+2+3=6=0x0006]
圆形[1+2+4=7=0x0007]
三角形[1+3=4=0x0004]
五边形[2+4=6=0x0006]
这个碰撞具体会怎样呢?矩形跟五边形竟然一样!6跟7少说也有两种组合方法,还是直接看Demo好了。
结果:
矩形:只跟圆形发生碰撞。6跟2有什么关系?
圆形:只跟自身,矩形,五边形发生碰撞。符合要求。赞一个!
三角形:只跟五边形发生碰撞。4跟4,是不是单一比组合优先?
五边形:只跟自身,圆形,三角形发生碰撞。6 = 2+3+4??我勒个去!
还是先看看正确的把!
一切一切的错误就是categoryBits值有些取值是违规的,categoryBits值是必须为2的倍数的。
即有如下的16个种群:
0x0000 = 0
0x0001 = 1
0x0002 = 2
0x0004 = 4
0x0008 = 8
0x0010 = 16
0x0020 = 32
0x0040 = 64
0x0080 = 128
0x0100 = 256
0x0200 = 512
0x0400 = 1024
0x0800 = 2048
0x1000 = 4096
0x2000 = 8192
0x4000 = 16384
0x8000 = 32768
这样子,6就只能跟2+4配对,8就只能跟8自己配对。