可可之王 - 我需要帮助!
我正在编写我的第一个应用程序(游戏),并尝试在 Core Frameworks 和 UIKit 中完成所有工作。我的游戏涉及一个由我手动创建的 UIButtons 制成的 5 x 8 板(!)。当我改变一个人的行为时要更新的大量 PItA。我尝试过使用可变数组和 UIButton 生成器,但我对这些东西仍然很糟糕,而且我在让事情正常工作方面非常不成功。
该按钮存储它的状态、价值、所有者和来源。我目前有 A、B、C、D、E 重新表示列,1-8 表示行。按钮为 62x62,网格两侧有 1 个像素的边距,按钮之间有 2 个像素的缓冲区和边距。
有人可以帮我从一个我为每个按钮指定标签、值等的类中获得一个不错的小数组生成器,并以编程方式吐出网格吗?
按钮示例:
-(IBAction) buttonA1:(id)sender {
UIButton *theButton = (UIButton *)sender;
theButton.titleLabel.font = [UIFont fontWithName:@"Gotham Rounded" size:22];
NSString *Title = theButton.titleLabel.text;
if (tapA1 != 1) {
[theButton setAlpha:1.0];
tapSum++;
tapA1 = 1;
[theButton setTitle: @"A1" forState: UIControlStateNormal];
NSLog(@"Press recieved from %@:\n\nSum is %i.\n", Title, tapSum);
[theButton setBackgroundImage:[UIImage imageNamed:@"red-dot.png"] forState:UIControlStateNormal];
}
else if (tapA1 == 1)
{
[theButton setAlpha:0.3];
tapA1 = 0;
tapSum--;
NSLog(@"Press recieved from %@:\n\nSum is %i.\n", Title, tapSum);
}
提前致谢!