This repository has been archived by the owner on Jul 6, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
304 changed files
with
72,060 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* cocoshop | ||
* | ||
* Copyright (c) 2011 Andrew | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
#import "cocos2d.h" | ||
|
||
@interface CCNode (Additions) | ||
|
||
@property (nonatomic, readonly) CGRect rect; | ||
|
||
- (BOOL)isEventInRect:(NSEvent *)event; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* cocoshop | ||
* | ||
* Copyright (c) 2011 Andrew | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
#import "CCNode+Additions.h" | ||
|
||
@implementation CCNode (Additions) | ||
|
||
@dynamic rect; | ||
|
||
- (CGRect)rect | ||
{ | ||
return CGRectMake(self.position.x - contentSize_.width*anchorPoint_.x, self.position.y- | ||
contentSize_.height*anchorPoint_.y, | ||
contentSize_.width, contentSize_.height); | ||
} | ||
|
||
- (BOOL)isEventInRect:(NSEvent *)event | ||
{ | ||
CGPoint location = [[CCDirector sharedDirector] convertEventToGL:event]; | ||
CGPoint local = [self convertToNodeSpace:location]; | ||
CGRect r = self.rect; | ||
r.origin = CGPointZero; | ||
return CGRectContainsPoint(r, local); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* cocoshop | ||
* | ||
* Copyright (c) 2011 Andrew | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@class CSSprite; | ||
|
||
@interface CSModel : NSObject | ||
{ | ||
NSMutableDictionary *spriteDictionary_; | ||
NSString *selectedSpriteKey_; | ||
|
||
NSString *name_; | ||
float posX_; | ||
float posY_; | ||
float posZ_; | ||
float anchorX_; | ||
float anchorY_; | ||
float scale_; | ||
NSInteger flipX_; | ||
NSInteger flipY_; | ||
float opacity_; | ||
NSColor *color_; | ||
NSInteger relativeAnchor_; | ||
} | ||
|
||
@property(nonatomic, retain) NSMutableDictionary *spriteDictionary; | ||
@property(nonatomic, copy) NSString *selectedSpriteKey; | ||
@property(nonatomic, assign) NSString *name; | ||
@property(nonatomic, assign) float posX; | ||
@property(nonatomic, assign) float posY; | ||
@property(nonatomic, assign) float posZ; | ||
@property(nonatomic, assign) float anchorX; | ||
@property(nonatomic, assign) float anchorY; | ||
@property(nonatomic, assign) float scale; | ||
@property(nonatomic, assign) NSInteger flipX; | ||
@property(nonatomic, assign) NSInteger flipY; | ||
@property(nonatomic, assign) float opacity; | ||
@property(nonatomic, copy) NSColor *color; | ||
@property(nonatomic, assign) NSInteger relativeAnchor; | ||
|
||
- (CSSprite *)selectedSprite; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* cocoshop | ||
* | ||
* Copyright (c) 2011 Andrew | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
#import "CSModel.h" | ||
#import "CSSprite.h" | ||
|
||
@implementation CSModel | ||
|
||
@synthesize spriteDictionary=spriteDictionary_; | ||
@synthesize selectedSpriteKey=selectedSpriteKey_; | ||
@synthesize name=name_; | ||
@synthesize posX=posX_; | ||
@synthesize posY=posY_; | ||
@synthesize posZ=posZ_; | ||
@synthesize anchorX=anchorX_; | ||
@synthesize anchorY=anchorY_; | ||
@synthesize scale=scale_; | ||
@synthesize flipX=flipX_; | ||
@synthesize flipY=flipY_; | ||
@synthesize opacity=opacity_; | ||
@synthesize color=color_; | ||
@synthesize relativeAnchor=relativeAnchor_; | ||
|
||
- (void)awakeFromNib | ||
{ | ||
[self setSpriteDictionary:[NSMutableDictionary dictionary]]; | ||
[self setSelectedSpriteKey:nil]; | ||
} | ||
|
||
- (CSSprite *)selectedSprite | ||
{ | ||
return [spriteDictionary_ objectForKey:selectedSpriteKey_]; | ||
} | ||
|
||
#pragma mark Custom Accessors | ||
|
||
- (void)setSelectedSpriteKey:(NSString *)aKey | ||
{ | ||
if(selectedSpriteKey_ != aKey) | ||
{ | ||
// deselect old sprite | ||
CSSprite *old = [self selectedSprite]; | ||
if(old) | ||
{ | ||
[[old border] setVisible:NO]; | ||
} | ||
|
||
[selectedSpriteKey_ release]; | ||
selectedSpriteKey_ = [aKey copy]; | ||
|
||
// select new sprite | ||
CSSprite *new = [self selectedSprite]; | ||
if(new) | ||
{ | ||
NSString *name = [new name]; | ||
CGPoint pos = [new position]; | ||
CGPoint anchor = [new anchorPoint]; | ||
float opacity = [new opacity]; | ||
NSInteger relAnchor = ( [new isRelativeAnchorPoint] ) ? NSOnState : NSOffState; | ||
|
||
[[new border] setVisible:YES]; | ||
[self setName:name]; | ||
[self setPosX:pos.x]; | ||
[self setPosY:pos.y]; | ||
[self setAnchorX:anchor.x]; | ||
[self setAnchorY:anchor.y]; | ||
[self setOpacity:opacity]; | ||
[self setRelativeAnchor:relAnchor]; | ||
} | ||
} | ||
} | ||
|
||
- (void)setOpacity:(float)anOpacity | ||
{ | ||
opacity_ = floorf(anOpacity); | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[self setSpriteDictionary:nil]; | ||
[self setSelectedSpriteKey:nil]; | ||
[self setSelectedSpriteKey:nil]; | ||
[self setColor:nil]; | ||
[super dealloc]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* cocoshop | ||
* | ||
* Copyright (c) 2011 Andrew | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import "cocos2d.h" | ||
|
||
@class CSModel; | ||
@class HelloWorldLayer; | ||
|
||
@interface CSObjectController : NSObjectController | ||
{ | ||
CSModel *modelObject_; | ||
HelloWorldLayer *cocosView_; | ||
|
||
IBOutlet NSPanel *infoPanel_; | ||
IBOutlet NSTextField *nameField_; | ||
IBOutlet NSTextField *posXField_; | ||
IBOutlet NSStepper *posXStepper_; | ||
IBOutlet NSTextField *posYField_; | ||
IBOutlet NSStepper *posYStepper_; | ||
IBOutlet NSTextField *posZField_; | ||
IBOutlet NSStepper *posZStepper_; | ||
IBOutlet NSTextField *anchorXField_; | ||
IBOutlet NSStepper *anchorXStepper_; | ||
IBOutlet NSTextField *anchorYField_; | ||
IBOutlet NSStepper *anchorYStepper_; | ||
IBOutlet NSTextField *scaleField_; | ||
IBOutlet NSStepper *scaleStepper_; | ||
IBOutlet NSButton *flipXButton_; | ||
IBOutlet NSButton *flipYButton_; | ||
IBOutlet NSTextField *opacityField_; | ||
IBOutlet NSSlider *opacitySlider_; | ||
IBOutlet NSButton *relativeAnchorButton_; | ||
} | ||
|
||
@property(assign) IBOutlet CSModel *modelObject; | ||
@property(nonatomic, retain) HelloWorldLayer *cocosView; | ||
|
||
- (IBAction)addSprite:(id)sender; | ||
- (IBAction)openInfoPanel:(id)sender; | ||
|
||
@end |
Oops, something went wrong.