Skip to content

Commit

Permalink
拼图游戏
Browse files Browse the repository at this point in the history
  • Loading branch information
BigShow1949 committed Sep 7, 2016
1 parent b5c34e7 commit 1456d7e
Show file tree
Hide file tree
Showing 13 changed files with 496 additions and 2 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified .svn/wc.db
Binary file not shown.
30 changes: 30 additions & 0 deletions BigShow1949.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,10 @@
1873D7311D8006EA008C2D1D /* 1.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1873D72E1D8006EA008C2D1D /* 1.plist */; };
1873D7321D8006EA008C2D1D /* 2.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1873D72F1D8006EA008C2D1D /* 2.plist */; };
1873D7331D8006EA008C2D1D /* 3.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1873D7301D8006EA008C2D1D /* 3.plist */; };
1873D7771D801CD1008C2D1D /* YFJigsawViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1873D7721D801CD1008C2D1D /* YFJigsawViewController.m */; };
1873D7781D801CD1008C2D1D /* YFCard.m in Sources */ = {isa = PBXBuildFile; fileRef = 1873D7741D801CD1008C2D1D /* YFCard.m */; };
1873D7791D801CD1008C2D1D /* YFChessBoardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1873D7761D801CD1008C2D1D /* YFChessBoardView.m */; };
1873D77B1D8021AE008C2D1D /* img1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 1873D77A1D8021AE008C2D1D /* img1.jpg */; };
18C2D5331BAEDC98006CD3B2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18C2D5311BAEDC61006CD3B2 /* UIKit.framework */; };
18C2D5361BAEDCC8006CD3B2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18C2D5341BAEDCAC006CD3B2 /* Foundation.framework */; };
18C2D5381BAEDCD2006CD3B2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18C2D5371BAEDCD2006CD3B2 /* CoreGraphics.framework */; };
Expand Down Expand Up @@ -1602,6 +1606,13 @@
1873D72E1D8006EA008C2D1D /* 1.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = 1.plist; sourceTree = "<group>"; };
1873D72F1D8006EA008C2D1D /* 2.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = 2.plist; sourceTree = "<group>"; };
1873D7301D8006EA008C2D1D /* 3.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = 3.plist; sourceTree = "<group>"; };
1873D7711D801CD1008C2D1D /* YFJigsawViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YFJigsawViewController.h; sourceTree = "<group>"; };
1873D7721D801CD1008C2D1D /* YFJigsawViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YFJigsawViewController.m; sourceTree = "<group>"; };
1873D7731D801CD1008C2D1D /* YFCard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YFCard.h; sourceTree = "<group>"; };
1873D7741D801CD1008C2D1D /* YFCard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YFCard.m; sourceTree = "<group>"; };
1873D7751D801CD1008C2D1D /* YFChessBoardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YFChessBoardView.h; sourceTree = "<group>"; };
1873D7761D801CD1008C2D1D /* YFChessBoardView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YFChessBoardView.m; sourceTree = "<group>"; };
1873D77A1D8021AE008C2D1D /* img1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = img1.jpg; sourceTree = "<group>"; };
18C2D5311BAEDC61006CD3B2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
18C2D5341BAEDCAC006CD3B2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
18C2D5371BAEDCD2006CD3B2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -2602,6 +2613,7 @@
186E6C151D70262D0070A717 /* 08 - LittleProject(小项目展示) */ = {
isa = PBXGroup;
children = (
1873D7701D801CC8008C2D1D /* Jigsaw */,
186E6C161D70262D0070A717 /* 01 - RotateButton */,
186E6C1A1D70262D0070A717 /* 02 - EmotionsKeyboard */,
186E6C341D70262D0070A717 /* 03 - 2048 */,
Expand Down Expand Up @@ -4365,6 +4377,19 @@
path = UICollectionView;
sourceTree = "<group>";
};
1873D7701D801CC8008C2D1D /* Jigsaw */ = {
isa = PBXGroup;
children = (
1873D7711D801CD1008C2D1D /* YFJigsawViewController.h */,
1873D7721D801CD1008C2D1D /* YFJigsawViewController.m */,
1873D7731D801CD1008C2D1D /* YFCard.h */,
1873D7741D801CD1008C2D1D /* YFCard.m */,
1873D7751D801CD1008C2D1D /* YFChessBoardView.h */,
1873D7761D801CD1008C2D1D /* YFChessBoardView.m */,
);
path = Jigsaw;
sourceTree = "<group>";
};
18C2D52F1BAEDC2C006CD3B2 /* Framework */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4418,6 +4443,7 @@
8B0B9AB21B9572000084590D /* Supporting Files */ = {
isa = PBXGroup;
children = (
1873D77A1D8021AE008C2D1D /* img1.jpg */,
B84C03281CE2E04700E62D75 /* 1.mp4 */,
18C760021B9AB24A0038B2EE /* lxh */,
18C760031B9AB24A0038B2EE /* default */,
Expand Down Expand Up @@ -4630,6 +4656,7 @@
186E6F7B1D70262E0070A717 /* YFShopCell.xib in Resources */,
186E706E1D70262E0070A717 /* [email protected] in Resources */,
186E6F981D70262E0070A717 /* HHHeaderView.xib in Resources */,
1873D77B1D8021AE008C2D1D /* img1.jpg in Resources */,
186E6F3D1D70262E0070A717 /* [email protected] in Resources */,
186E6F651D70262E0070A717 /* coffee_to_go-50.png in Resources */,
186E70761D70262E0070A717 /* [email protected] in Resources */,
Expand Down Expand Up @@ -4675,6 +4702,7 @@
186E6F751D70262E0070A717 /* SSStackedPageView.m in Sources */,
186E6FF91D70262E0070A717 /* SYEmotion.m in Sources */,
186E6FAC1D70262E0070A717 /* RZTransitionsManager.m in Sources */,
1873D7781D801CD1008C2D1D /* YFCard.m in Sources */,
186E6F4A1D70262E0070A717 /* YFTagsCloudViewController.m in Sources */,
186E70601D70262E0070A717 /* HyTransitions.m in Sources */,
186E70891D70262E0070A717 /* MenuItemCell.m in Sources */,
Expand Down Expand Up @@ -4712,6 +4740,7 @@
186E6FE11D70262E0070A717 /* YFNotificationCenterVC.m in Sources */,
186E71241D70262E0070A717 /* MJFoundation.m in Sources */,
186E71351D70262E0070A717 /* MKAnnotationView+WebCache.m in Sources */,
1873D7771D801CD1008C2D1D /* YFJigsawViewController.m in Sources */,
186E6FF61D70262E0070A717 /* ViewController.m in Sources */,
186E6F951D70262E0070A717 /* HHContentScrollView.m in Sources */,
186E70451D70262E0070A717 /* YFCircleLoader.m in Sources */,
Expand Down Expand Up @@ -4823,6 +4852,7 @@
186E6F3B1D70262E0070A717 /* YFLazyInViewController.m in Sources */,
186E6F401D70262E0070A717 /* YFCycleView.m in Sources */,
186E6F971D70262E0070A717 /* HHHeaderView.m in Sources */,
1873D7791D801CD1008C2D1D /* YFChessBoardView.m in Sources */,
186E6F821D70262E0070A717 /* TempViewController.m in Sources */,
186E6F2C1D70262E0070A717 /* DWBubbleMenuButton.m in Sources */,
186E71021D70262E0070A717 /* AFHTTPRequestOperationManager.m in Sources */,
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// YFCard.h
// Jigsaw
//
// Created by apple on 16/8/27.
// Copyright © 2016年 apple. All rights reserved.
//

#import <UIKit/UIKit.h>

//typedef struct{
// int X;
// int Y;
//};
//typedef struct Position position;
//
//
//CG_INLINE Position
//PointMake(CGFloat x, CGFloat y) {
// CGPoint p;
// p.x = x;
// p.y = y;
// return p;
//}

struct CardPosition{
int X;
int Y;
};
typedef struct CardPosition Position;

CG_INLINE Position
PositionMake(int X, int Y)
{
Position position;
position.X = X;
position.Y = Y;
return position;
}


@interface YFCard : UIImageView

- (void)moveToTarget:(id)target action:(SEL)action;

- (void)setDefaultFrame;


// 原始位置
@property (nonatomic, assign) Position originPosition;

// 当前位置
@property (nonatomic, assign) Position position;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// YFCard.m
// Jigsaw
//
// Created by apple on 16/8/27.
// Copyright © 2016年 apple. All rights reserved.
//

#import "YFCard.h"

@implementation YFCard

- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.userInteractionEnabled = YES;
}
return self;
}

- (void)setDefaultFrame {
CGRect tempF = self.frame;
tempF.origin.x = self.position.X * tempF.size.width;
tempF.origin.y = self.position.Y * tempF.size.height;
self.frame = tempF;

}

///**
// * 根据position计算位置
// */
//- (void)setPosition:(Position)position {
//
// _position = position;
//
// CGRect tempF = self.frame;
// tempF.origin.x = position.X * tempF.size.width;
// tempF.origin.y = position.Y * tempF.size.height;
// self.frame = tempF;
//}

- (void)moveToTarget:(id)target action:(SEL)action {

[UIView animateWithDuration:0.2f animations:^{
CGRect f = self.frame;
f.origin.x = self.position.X * self.frame.size.width;
f.origin.y = self.position.Y * self.frame.size.height;
self.frame=f;
} completion:^(BOOL finished) {
if (target) {
[target performSelector:action];
}
}];
}

- (NSString *)description {

return [NSString stringWithFormat:@"x:%zd, y:%zd", self.position.X, self.position.Y];
}
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// YFChessBoardView.h
// Jigsaw
//
// Created by apple on 16/8/27.
// Copyright © 2016年 apple. All rights reserved.
//

#import <UIKit/UIKit.h>

// 一定是个正方形
@interface YFChessBoardView : UIImageView

@property (nonatomic, strong) UIImage *backgroundImage;

- (void)randomBreak;

@end
Loading

0 comments on commit 1456d7e

Please sign in to comment.