CoverView.m
资源名称:PushBox.rar [点击查看]
上传用户:qhdwjd2004
上传日期:2020-12-29
资源大小:362k
文件大小:3k
源码类别:
iPhone
开发平台:
Objective-C
- #import "CoverView.h"
- #import "MainView.h"
- @implementation CoverView
- - (id)initWithFrame:(CGRect)rect
- {
- if ((self == [ super initWithFrame: rect ]) != nil) {
- // Start New Game
- StartImage = [UIImage applicationImageNamed: @"images/btnstart.png"];
- // Continue
- if(canContinue = [Map CheckMessExist])
- {
- ContinueImage = [UIImage applicationImageNamed: @"images/btncontinue1.png"];
- }
- else
- {
- ContinueImage = [UIImage applicationImageNamed: @"images/btncontinue2.png"];
- }
- // Load Stage
- CustomImage = [UIImage applicationImageNamed: @"images/btncustom.png"];
- // About
- AboutGameImage = [UIImage applicationImageNamed: @"images/btnabout.png"];
- int i;
- for(i=0;i<MenuNumber;i++)
- {
- menu[i] = CGRectMake(MenuX, MenuY + i*MenuItemHeight + MenuSplit, MenuWidth, MenuItemHeight);
- }
- }
- return self;
- }
- - (void)drawRect:(CGRect)rect
- {
- [ StartImage draw1PartImageInRect: menu[0] ];
- [ ContinueImage draw1PartImageInRect: menu[1] ];
- [ CustomImage draw1PartImageInRect: menu[2] ];
- [ AboutGameImage draw1PartImageInRect: menu[3] ];
- }
- - (void)dealloc
- {
- [StartImage release];
- [ContinueImage release];
- [CustomImage release];
- [AboutGameImage release];
- [ self dealloc ];
- [ super dealloc];
- }
- - (void)updateview
- {
- if(canContinue = [Map CheckMessExist])
- {
- ContinueImage = [UIImage applicationImageNamed: @"images/btncontinue1.png"];
- }
- else
- {
- ContinueImage = [UIImage applicationImageNamed: @"images/btncontinue2.png"];
- }
- [self setNeedsDisplayInRect:menu[1]];
- }
- - (void)setParentView:(UIView*)view;
- {
- parentView = view;
- }
- - (void)mouseDown: (struct __GSEvent *)event
- {
- MainView *mView = (MainView *)parentView;
- CGPoint p = GSEventGetInnerMostPathPosition(event);
- if([self isPoint:p InRect:menu[0]])
- {
- [mView startGame];
- return;
- }
- if([self isPoint:p InRect:menu[1]])
- {
- if(canContinue)
- {
- [mView continueGame];
- }
- return;
- }
- if([self isPoint:p InRect:menu[2]])
- {
- [(MainView*)mView customGame:NO];
- return;
- }
- if([self isPoint:p InRect:menu[3]])
- {
- [mView showAbout];
- return;
- }
- }
- - (bool)isPoint:(CGPoint)pt InRect:(CGRect)rect
- {
- if(pt.x>rect.origin.x && pt.x < rect.origin.x + rect.size.width
- && pt.y>rect.origin.y && pt.y < rect.origin.y + rect.size.height)
- {
- return YES;
- }
- else
- {
- return NO;
- }
- }
- @end