当添加了UIScrollView时,是否有人知道如何开始触摸以在SKSpritenodes上运行?目前UIScrollView只是自己添加。
我假设某种方式需要成为SKScene的孩子,但所有尝试都失败了。
-(void)didMoveToView:(SKView *)view {
pageScroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width-700, self.frame.size.height)];
pageScroller.contentSize = CGSizeMake(1530, self.frame.size.height);
pageScroller.userInteractionEnabled = YES;
pageScroller.delegate = self;
[self.scene.view addSubview:pageScroller];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches) {
CGPoint location = [touch locationInNode:self];
SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"Spaceship"];
sprite.xScale = 0.5;
sprite.yScale = 0.5;
sprite.position = location;
SKAction *action = [SKAction rotateByAngle:M_PI duration:1];
[sprite runAction:[SKAction repeatActionForever:action]];
[self addChild:sprite];
}
}
答案 0 :(得分:0)
完成后,目的是创建一个具有
的关卡框选择屏幕如果有人发现这个有用的话,那就是所有的代码,并且是一个有效的视频。 http://www.performancetrackerltd.com/#!tutorials/syjol
-(void)didMoveToView:(SKView *)view {
pageScroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width-700, self.frame.size.height)];
pageScroller.contentSize = CGSizeMake(1530, self.frame.size.height);
pageScroller.userInteractionEnabled = YES;
pageScroller.delegate = self;
[self.view addSubview:pageScroller];
[self addBoxLevels];
navigationBox1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
navigationBox1.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 30.0, 30.0);
navigationBox1.backgroundColor = [UIColor clearColor];
navigationBox1.center = CGPointMake(self.frame.size.width-928, self.frame.size.height-300);
[navigationBox1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ];
UIImage *navigationBox1BackStateImageNormal = [UIImage imageNamed:@"boxFilled"];
UIImage *strechablenavigationBox1BackStateImageNormal = [navigationBox1BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox1 setBackgroundImage:strechablenavigationBox1BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox1];
[navigationBox1 addTarget:self action:@selector(navigationBox1Action) forControlEvents:UIControlEventTouchUpInside];
navigationBox2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
navigationBox2.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 30.0, 30.0);
navigationBox2.backgroundColor = [UIColor clearColor];
navigationBox2.center = CGPointMake(self.frame.size.width-895, self.frame.size.height-300);
[navigationBox2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ];
UIImage *navigationBox2BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox2BackStateImageNormal = [navigationBox2BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox2 setBackgroundImage:strechablenavigationBox2BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox2];
[navigationBox2 addTarget:self action:@selector(navigationBox2Action) forControlEvents:UIControlEventTouchUpInside];
navigationBox3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
navigationBox3.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 30.0, 30.0);
navigationBox3.backgroundColor = [UIColor clearColor];
navigationBox3.center = CGPointMake(self.frame.size.width-862, self.frame.size.height-300);
[navigationBox3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ];
UIImage *navigationBox3BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox3BackStateImageNormal = [navigationBox3BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox3 setBackgroundImage:strechablenavigationBox3BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox3];
[navigationBox3 addTarget:self action:@selector(navigationBox3Action) forControlEvents:UIControlEventTouchUpInside];
navigationBox4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
navigationBox4.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 30.0, 30.0);
navigationBox4.backgroundColor = [UIColor clearColor];
navigationBox4.center = CGPointMake(self.frame.size.width-829, self.frame.size.height-300);
[navigationBox4 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ];
UIImage *navigationBox4BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox4BackStateImageNormal = [navigationBox4BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox4 setBackgroundImage:strechablenavigationBox4BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox4];
[navigationBox4 addTarget:self action:@selector(navigationBox4Action) forControlEvents:UIControlEventTouchUpInside];
}
-(void)navigationBox1Action{
[pageScroller setContentOffset:CGPointMake(0, pageScroller.contentOffset.y) animated:YES];
}
-(void)navigationBox2Action{
[pageScroller setContentOffset:CGPointMake(300, pageScroller.contentOffset.y) animated:YES];
}
-(void)navigationBox3Action{
[pageScroller setContentOffset:CGPointMake(600, pageScroller.contentOffset.y) animated:YES];
}
-(void)navigationBox4Action{
[pageScroller setContentOffset:CGPointMake(900, pageScroller.contentOffset.y) animated:YES];
}
-(void)navigationBoxes{
if (pageScroller.contentOffset.x < 200) {
UIImage *navigationBox1BackStateImageNormal = [UIImage imageNamed:@"boxFilled"];
UIImage *strechablenavigationBox1BackStateImageNormal = [navigationBox1BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox1 setBackgroundImage:strechablenavigationBox1BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox1];
UIImage *navigationBox2BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox2BackStateImageNormal = [navigationBox2BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox2 setBackgroundImage:strechablenavigationBox2BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox2];
UIImage *navigationBox3BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox3BackStateImageNormal = [navigationBox3BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox3 setBackgroundImage:strechablenavigationBox3BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox3];
UIImage *navigationBox4BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox4BackStateImageNormal = [navigationBox4BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox4 setBackgroundImage:strechablenavigationBox4BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox4];
} else {
if (pageScroller.contentOffset.x > 200 & pageScroller.contentOffset.x < 450) {
UIImage *navigationBox1BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox1BackStateImageNormal = [navigationBox1BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox1 setBackgroundImage:strechablenavigationBox1BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox1];
UIImage *navigationBox2BackStateImageNormal = [UIImage imageNamed:@"boxFilled"];
UIImage *strechablenavigationBox2BackStateImageNormal = [navigationBox2BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox2 setBackgroundImage:strechablenavigationBox2BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox2];
UIImage *navigationBox3BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox3BackStateImageNormal = [navigationBox3BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox3 setBackgroundImage:strechablenavigationBox3BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox3];
UIImage *navigationBox4BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox4BackStateImageNormal = [navigationBox4BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox4 setBackgroundImage:strechablenavigationBox4BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox4];
} else {
if (pageScroller.contentOffset.x > 451 & pageScroller.contentOffset.x < 750) {
UIImage *navigationBox1BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox1BackStateImageNormal = [navigationBox1BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox1 setBackgroundImage:strechablenavigationBox1BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox1];
UIImage *navigationBox2BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox2BackStateImageNormal = [navigationBox2BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox2 setBackgroundImage:strechablenavigationBox2BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox2];
UIImage *navigationBox3BackStateImageNormal = [UIImage imageNamed:@"boxFilled"];
UIImage *strechablenavigationBox3BackStateImageNormal = [navigationBox3BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox3 setBackgroundImage:strechablenavigationBox3BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox3];
UIImage *navigationBox4BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox4BackStateImageNormal = [navigationBox4BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox4 setBackgroundImage:strechablenavigationBox4BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox4];
} else {
if (pageScroller.contentOffset.x > 750 & pageScroller.contentOffset.x < 1000) {
UIImage *navigationBox1BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox1BackStateImageNormal = [navigationBox1BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox1 setBackgroundImage:strechablenavigationBox1BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox1];
UIImage *navigationBox2BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox2BackStateImageNormal = [navigationBox2BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox2 setBackgroundImage:strechablenavigationBox2BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox2];
UIImage *navigationBox3BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox3BackStateImageNormal = [navigationBox3BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox3 setBackgroundImage:strechablenavigationBox3BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox3];
UIImage *navigationBox4BackStateImageNormal = [UIImage imageNamed:@"boxFilled"];
UIImage *strechablenavigationBox4BackStateImageNormal = [navigationBox4BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox4 setBackgroundImage:strechablenavigationBox4BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox4];
} else {
if (pageScroller.contentOffset.x > 1001 & pageScroller.contentOffset.x < 1300) {
UIImage *navigationBox1BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox1BackStateImageNormal = [navigationBox1BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox1 setBackgroundImage:strechablenavigationBox1BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox1];
UIImage *navigationBox2BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox2BackStateImageNormal = [navigationBox2BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox2 setBackgroundImage:strechablenavigationBox2BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox2];
UIImage *navigationBox3BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox3BackStateImageNormal = [navigationBox3BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox3 setBackgroundImage:strechablenavigationBox3BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox3];
UIImage *navigationBox4BackStateImageNormal = [UIImage imageNamed:@"boxClear"];
UIImage *strechablenavigationBox4BackStateImageNormal = [navigationBox4BackStateImageNormal stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[navigationBox4 setBackgroundImage:strechablenavigationBox4BackStateImageNormal forState:UIControlStateNormal];
[self.view addSubview:navigationBox4];
}
}
}
}
}
}
-(void)addBoxLevels{
_season1TotalStars = [[NSUserDefaults standardUserDefaults] integerForKey:@"_season1TotalStars"];
season1Box1Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
season1Box1Button.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 250.0, 250.0);
season1Box1Button.backgroundColor = [UIColor clearColor];
season1Box1Button.center = CGPointMake(self.frame.size.width-855, self.frame.size.height-500);
[season1Box1Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *season1Box1ButtonImageButton = [UIImage imageNamed:@"box1"];
UIImage *strechableSeason1Box1ImageButton = [season1Box1ButtonImageButton stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[season1Box1Button setBackgroundImage:strechableSeason1Box1ImageButton forState:UIControlStateNormal];
[pageScroller addSubview:season1Box1Button];
[season1Box1Button addTarget:self action:@selector(moveToSeasons1Box1Levels) forControlEvents:UIControlEventTouchUpInside];
if (_season1TotalStars >= 40) {
season1Box2Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
season1Box2Button.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 250.0, 250.0);
season1Box2Button.backgroundColor = [UIColor clearColor];
// season1Box2Button.center = CGPointMake(470,250);
season1Box2Button.center = CGPointMake(self.frame.size.width-555, self.frame.size.height-500);
[season1Box2Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *season1Box2ButtonImageButton = [UIImage imageNamed:@"box2"];
UIImage *strechableSeason1Box2ImageButton = [season1Box2ButtonImageButton stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[season1Box2Button setBackgroundImage:strechableSeason1Box2ImageButton forState:UIControlStateNormal];
[pageScroller addSubview:season1Box2Button];
[season1Box2Button addTarget:self action:@selector(moveToSeasons1Box2Levels) forControlEvents:UIControlEventTouchUpInside];
} else {
season1Box2Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
season1Box2Button.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 250.0, 250.0);
season1Box2Button.backgroundColor = [UIColor clearColor];
// season1Box2Button.center = CGPointMake(470,250);
season1Box2Button.center = CGPointMake(self.frame.size.width-555, self.frame.size.height-500);
[season1Box2Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *season1Box2ButtonImageButton = [UIImage imageNamed:@"box2lock"];
UIImage *strechableSeason1Box2ImageButton = [season1Box2ButtonImageButton stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[season1Box2Button setBackgroundImage:strechableSeason1Box2ImageButton forState:UIControlStateNormal];
[pageScroller addSubview:season1Box2Button];
[season1Box2Button addTarget:self action:@selector(IAPunlockSeason1Box2) forControlEvents:UIControlEventTouchUpInside];
levelBox2StarCountToUnlock = [[UITextField alloc] initWithFrame:CGRectMake(self.size.width/2, self.size.height/2+20, 200, 40)];
levelBox2StarCountToUnlock.textColor = [UIColor whiteColor];
levelBox2StarCountToUnlock.font = [UIFont systemFontOfSize:30.0];
levelBox2StarCountToUnlock.text = @"40";
levelBox2StarCountToUnlock.enabled = NO;
levelBox2StarCountToUnlock.center = CGPointMake(self.frame.size.width-495, self.frame.size.height-492);
[pageScroller addSubview:levelBox2StarCountToUnlock];
}
if (_season1TotalStars >= 90) {
season1Box3Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
season1Box3Button.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 250.0, 250.0);
season1Box3Button.backgroundColor = [UIColor clearColor];
// season1Box3Button.center = CGPointMake(770,250);
season1Box3Button.center = CGPointMake(self.frame.size.width-255, self.frame.size.height-500);
[season1Box3Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *season1Box3ButtonImageButton = [UIImage imageNamed:@"box3"];
UIImage *strechableSeason1Box3ImageButton = [season1Box3ButtonImageButton stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[season1Box3Button setBackgroundImage:strechableSeason1Box3ImageButton forState:UIControlStateNormal];
[pageScroller addSubview:season1Box3Button];
[season1Box3Button addTarget:self action:@selector(moveToSeasons1Box3Levels) forControlEvents:UIControlEventTouchUpInside];
} else {
season1Box3Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
season1Box3Button.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 250.0, 250.0);
season1Box3Button.backgroundColor = [UIColor clearColor];
// season1Box3Button.center = CGPointMake(770,250);
season1Box3Button.center = CGPointMake(self.frame.size.width-255, self.frame.size.height-500);
[season1Box3Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *season1Box3ButtonImageButton = [UIImage imageNamed:@"box3lock"];
UIImage *strechableSeason1Box3ImageButton = [season1Box3ButtonImageButton stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[season1Box3Button setBackgroundImage:strechableSeason1Box3ImageButton forState:UIControlStateNormal];
[pageScroller addSubview:season1Box3Button];
[season1Box3Button addTarget:self action:@selector(IAPunlockSeason1Box3) forControlEvents:UIControlEventTouchUpInside];
levelBox3StarCountToUnlock = [[UITextField alloc] initWithFrame:CGRectMake(self.size.width/2, self.size.height/2+20, 200, 40)];
levelBox3StarCountToUnlock.textColor = [UIColor whiteColor];
levelBox3StarCountToUnlock.font = [UIFont systemFontOfSize:30.0];
levelBox3StarCountToUnlock.text = @"90";
levelBox3StarCountToUnlock.enabled = NO;
levelBox3StarCountToUnlock.center = CGPointMake(self.frame.size.width-195, self.frame.size.height-492);
[pageScroller addSubview:levelBox3StarCountToUnlock];
}
if (_season1TotalStars >=180) {
season1Box4Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
season1Box4Button.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 250.0, 250.0);
season1Box4Button.backgroundColor = [UIColor clearColor];
// season1Box4Button.center = CGPointMake(1070,250);
season1Box4Button.center = CGPointMake(self.frame.size.width+45, self.frame.size.height-500);
[season1Box4Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *season1Box4ButtonImageButton = [UIImage imageNamed:@"box4"];
UIImage *strechableSeason1Box4ImageButton = [season1Box4ButtonImageButton stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[season1Box4Button setBackgroundImage:strechableSeason1Box4ImageButton forState:UIControlStateNormal];
[pageScroller addSubview:season1Box4Button];
[season1Box4Button addTarget:self action:@selector(moveToSeasons1Box4Levels) forControlEvents:UIControlEventTouchUpInside];
} else {
season1Box4Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
season1Box4Button.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 250.0, 250.0);
season1Box4Button.backgroundColor = [UIColor clearColor];
// season1Box4Button.center = CGPointMake(1070,250);
season1Box4Button.center = CGPointMake(self.frame.size.width+45, self.frame.size.height-500);
[season1Box4Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *season1Box4ButtonImageButton = [UIImage imageNamed:@"box4lock"];
UIImage *strechableSeason1Box4ImageButton = [season1Box4ButtonImageButton stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[season1Box4Button setBackgroundImage:strechableSeason1Box4ImageButton forState:UIControlStateNormal];
[pageScroller addSubview:season1Box4Button];
[season1Box4Button addTarget:self action:@selector(IAPunlockSeason1Box4) forControlEvents:UIControlEventTouchUpInside];
levelBox4StarCountToUnlock = [[UITextField alloc] initWithFrame:CGRectMake(self.size.width/2, self.size.height/2+20, 200, 40)];
levelBox4StarCountToUnlock.textColor = [UIColor whiteColor];
levelBox4StarCountToUnlock.font = [UIFont systemFontOfSize:23.0];
levelBox4StarCountToUnlock.text = @"180";
levelBox4StarCountToUnlock.enabled = NO;
levelBox4StarCountToUnlock.center = CGPointMake(self.frame.size.width+107, self.frame.size.height-493);
[pageScroller addSubview:levelBox4StarCountToUnlock];
}
season2Button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
season2Button.frame = CGRectMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame), 200.0, 200.0);
season2Button.backgroundColor = [UIColor clearColor];
season2Button.center = CGPointMake(self.frame.size.width+345, self.frame.size.height-500);
[season2Button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal ];
UIImage *season2ImageButton = [UIImage imageNamed:@"season3"];
UIImage *strechableSeason2ImageButton = [season2ImageButton stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[season2Button setBackgroundImage:strechableSeason2ImageButton forState:UIControlStateNormal];
[pageScroller addSubview:season2Button];
[season2Button addTarget:self action:@selector(movetoSeason2) forControlEvents:UIControlEventTouchUpInside];
season2Label = [[UITextField alloc] initWithFrame:CGRectMake(self.size.width/2, self.size.height/2+20, 200, 40)];
season2Label.textColor = [UIColor whiteColor];
season2Label.font = [UIFont systemFontOfSize:23.0];
season2Label.text = @"Season 2";
season2Label.enabled = NO;
season2Label.center = CGPointMake(self.frame.size.width+397, self.frame.size.height-618);
[pageScroller addSubview:season2Label];
season2LabelComingSoonLabel = [[UITextField alloc] initWithFrame:CGRectMake(self.size.width/2, self.size.height/2+20, 200, 40)];
season2LabelComingSoonLabel.textColor = [UIColor whiteColor];
season2LabelComingSoonLabel.font = [UIFont systemFontOfSize:23.0];
season2LabelComingSoonLabel.text = @"Coming soon";
season2LabelComingSoonLabel.enabled = NO;
season2LabelComingSoonLabel.center = CGPointMake(self.frame.size.width+375, self.frame.size.height-380);
[pageScroller addSubview:season2LabelComingSoonLabel];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)pageScroller
{
[self stoppedScrolling];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)pageScroller
willDecelerate:(BOOL)decelerate
{
if (!decelerate) {
[self stoppedScrolling];
}
}
- (void)stoppedScrolling
{
if (pageScroller.contentOffset.x < 160) {
[pageScroller setContentOffset:CGPointMake(0, pageScroller.contentOffset.y) animated:YES];
} else {
if (pageScroller.contentOffset.x > 161 & pageScroller.contentOffset.x < 399) {
[pageScroller setContentOffset:CGPointMake(300, pageScroller.contentOffset.y) animated:YES];
} else {
if (pageScroller.contentOffset.x > 400 & pageScroller.contentOffset.x < 700) {
[pageScroller setContentOffset:CGPointMake(600, pageScroller.contentOffset.y) animated:YES];
} else {
if (pageScroller.contentOffset.x > 701 & pageScroller.contentOffset.x < 1050) {
[pageScroller setContentOffset:CGPointMake(900, pageScroller.contentOffset.y) animated:YES];
} else {
if (pageScroller.contentOffset.x > 1051 & pageScroller.contentOffset.x < 1300) {
[pageScroller setContentOffset:CGPointMake(1200, pageScroller.contentOffset.y) animated:YES];
} else {
}
}
}
}
}
}
-(void)update:(CFTimeInterval)currentTime {
/* Called before each frame is rendered */
[self navigationBoxes];
}