Skip to content

Commit

Permalink
SpriteBuilder crashes when the the user select " Select Behind" for a…
Browse files Browse the repository at this point in the history
…n object.

Prevent issue spritebuilder#1584 to happen
But does not enable user to use menu "Select Behind" before a CCNode is clicked in the GLView
Tried to implement a definitive solution in CocosScene - (void) updateSelection but it does not work yet, so it's commented
  • Loading branch information
oxeron committed Mar 11, 2016
1 parent b0d2ee1 commit 73c3b29
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SpriteBuilder/ccBuilder/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -4200,7 +4200,7 @@ - (BOOL) validateMenuItem:(NSMenuItem *)menuItem
else if (menuItem.action == @selector(menuSelectBehind:))
{
if (!hasOpenedDocument) return NO;
return (self.selectedNode != NULL);
return (self.selectedNode != NULL && [[CocosScene cocosScene] currentNodeAtSelectionPtIdx] != NULL);
}
else if (menuItem.action == @selector(selectNextTab:))
{
Expand Down
6 changes: 4 additions & 2 deletions SpriteBuilder/ccBuilder/CocosScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ enum {

// Selection
NSMutableArray* nodesAtSelectionPt;
int currentNodeAtSelectionPtIdx;


CCNodeColor* borderBottom;
CCNodeColor* borderTop;
Expand All @@ -146,6 +146,8 @@ enum {
CGPoint effectSpriteDraggingLocation;
}

@property (nonatomic,readonly) int currentNodeAtSelectionPtIdx;

@property (nonatomic) CCNode* rootNode;

@property (nonatomic,readonly) BOOL isMouseTransforming;
Expand Down Expand Up @@ -198,7 +200,7 @@ enum {
- (void)mouseExited:(NSEvent *)event;
- (void)cursorUpdate:(NSEvent *)event;

//Draggin
//Dragging
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender pos:(CGPoint)pos;
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender pos:(CGPoint)pos;
- (void)draggingExited:(id <NSDraggingInfo>)sender pos:(CGPoint)pos;
Expand Down
5 changes: 3 additions & 2 deletions SpriteBuilder/ccBuilder/CocosScene.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ @implementation CocosScene
@synthesize physicsLayer;
@synthesize lightIconsLayer;
@synthesize stageLight;
@synthesize currentNodeAtSelectionPtIdx;

+(id) sceneWithAppDelegate:(AppDelegate*)app
{
Expand Down Expand Up @@ -521,8 +522,9 @@ - (void) updateSelection
for (CCNode* node in nodes)
{
// Refresh informations for "Select Behind" called from outlineHierarchy

/*
[nodesAtSelectionPt removeAllObjects];
//[nodesAtSelectionPt removeAllObjects];
CGPoint worldPos = [node convertToWorldSpace:node.position];
[self nodesUnderPt:worldPos rootNode:rootNode nodes:nodesAtSelectionPt];
[[jointsLayer.children.firstObject children] forEach:^(CCNode * jointNode, int idx) {
Expand Down Expand Up @@ -1288,7 +1290,6 @@ - (void) mouseDown:(NSEvent *)event
// shortcut for Select Behind: Alt + LeftClick
if ([event modifierFlags] & NSAlternateKeyMask)
{
NSLog(@"selectBehind");
[self selectBehind];
}

Expand Down

0 comments on commit 73c3b29

Please sign in to comment.