サイモンゲーム ソース公開(その6)
以前作成していたサイモンゲームのソースを公開していってます。
Objective-Cを十分理解出来ていない時に、作成してますので、
おかしい使い方をしているかもしれません。
例えば、プロパティの初期化なんてset〜を使用するべきでしょうし・・・
まぁ、ツッコミどころ満載ですが、公開します。
今回は、「UIImageViewPlus.h」と「UIImageViewPlus.m」を書いておきます。
UIImageViewPlus.h
#import <Foundation/Foundation.h>@interface UIImageViewPlus : UIImageView {
CGPoint startLocation;
NSString *offStringPath;
NSString *onStringPath;
NSInteger number;
NSInteger on_x;
NSInteger on_y;
NSInteger off_x;
NSInteger off_y;
Boolean lockFLG;
IBOutlet id windowID;
}
- (void) lightOff;
- (void) lightOn;
- (void) setLockFLG:(Boolean)setFLG;- (void) setData:(NSString *)offPath
onPath:(NSString *)onPath
num:(NSInteger)num
off_x:(CGFloat)_off_x
off_y:(CGFloat)_off_y
on_x:(CGFloat)_on_x
on_y:(CGFloat)_on_y
width:(CGFloat)_width
height:(CGFloat)_height;
@end
UIImageViewPlus.m
#import "UIImageViewPlus.h"@implementation UIImageViewPlus
- (void) setLockFLG:(Boolean) setFLG
{
lockFLG = setFLG;
}- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
if( ( number != 0 ) && (lockFLG == FALSE ))
{
CGRect frame = [self frame];
frame.origin.x = on_x;
frame.origin.y = on_y;
[self setFrame:frame];
[self setImage:[UIImage imageNamed:onStringPath]];
[windowID pushImage:number];
}
}- (void)lightOn
{
[self setImage:[UIImage imageNamed:onStringPath]];
}- (void)lightOff
{
CGRect frame = [self frame];
frame.origin.x = off_x;
frame.origin.y = off_y;
[self setFrame:frame];
[self setImage:[UIImage imageNamed:offStringPath]];
}- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if( number != 0 )
{
CGRect frame = [self frame];
frame.origin.x = off_x;
frame.origin.y = off_y;
[self setFrame:frame];
[self setImage:[UIImage imageNamed:offStringPath]];
}
}- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
lockFLG = TRUE;
}
return self;
}- (void)drawRect:(CGRect)rect {
}-(void) setData:(NSString *)offPath
onPath:(NSString *)onPath
num:(NSInteger)num
off_x:(CGFloat)_off_x
off_y:(CGFloat)_off_y
on_x:(CGFloat)_on_x
on_y:(CGFloat)_on_y
width:(CGFloat)_width
height:(CGFloat)_height
{
offStringPath = [offPath copy];
offStringPath = [[NSString alloc] initWithString:offPath];
if ( onPath != nil )
onStringPath = [[NSString alloc] initWithString:onPath];
else
onStringPath = nil;
number = num;
[self setImage:[UIImage imageNamed:offStringPath]];
on_x = _on_x; on_y = _on_y;
off_x = _off_x; off_y = _off_y;
CGRect frame = [self frame];
frame.origin.x = off_x; frame.origin.y = off_y;
frame.size.width = _width; frame.size.height = _height;
[self setFrame:frame];
}- (void)dealloc {
[offStringPath release];
[onStringPath release];
[super dealloc];
}@end
以上。
本日はここまで。
次回は、「PlistDataClass.h」と「PlistDataClass.m」です。