public static float LocalXAngleFromGlobalAngle(CCNode node, float globalAngle) { for (CCNode p = node.Parent; p != null && p.GetType() != typeof(CCScene); p = p.Parent) { globalAngle -= p.RotationX; } return(globalAngle); }
public static CCPoint ConvertToWorldScale(CCNode node, CCPoint nodeScale) { for (CCNode p = node.Parent; p != null && p.GetType() != typeof(CCScene); p = p.Parent) { nodeScale.X *= p.ScaleX; nodeScale.Y *= p.ScaleY; } return(nodeScale); }
static CCAffineTransform NodeToB2BodyTransform(CCNode node) { CCAffineTransform transform = CCAffineTransform.Identity; for (CCNode n = node; n != null && n.GetType() != typeof(LHGameWorldNode) // && ![n isKindOfClass:[LHBackUINode class]] // && ![n isKindOfClass:[LHUINode class]] ; n = n.Parent) { transform = CCAffineTransform.Concat(transform, n.AffineLocalTransform); } return(transform); }
public void loadGenericInfoFromDictionary(PlistDictionary dict, CCNode nd) { b2WorldDirty = false; _node = nd; if (null != dict) { name = dict ["name"].AsString; uuid = dict ["uuid"].AsString; //tags loading // { // NSArray* loadedTags = [dict objectForKey:@"tags"]; // if(loadedTags){ // _tags = [[NSMutableArray alloc] initWithArray:loadedTags]; // } // } //user properties loading // { // NSDictionary* userPropInfo = [dict objectForKey:@"userPropertyInfo"]; // NSString* userPropClassName = [dict objectForKey:@"userPropertyName"]; // if(userPropInfo && userPropClassName) // { // Class userPropClass = NSClassFromString(userPropClassName); // if(userPropClass){ // #pragma clang diagnostic push // #pragma clang diagnostic ignored "-Wundeclared-selector" // _userProperty = [userPropClass performSelector:@selector(customClassInstanceWithNode:) // withObject:_node]; // #pragma clang diagnostic pop // if(_userProperty){ // [_userProperty setPropertiesFromDictionary:userPropInfo]; // } // } // } // } if (dict.ContainsKey("alpha")) { _node.Opacity = (byte)dict ["alpha"].AsFloat; } if (dict.ContainsKey("rotation")) { _node.Rotation = -dict ["rotation"].AsFloat; } if (dict.ContainsKey("zOrder")) { _node.ZOrder = dict ["zOrder"].AsInt; } if (dict.ContainsKey("scale")) { CCPoint scl = CCPoint.Parse(dict ["scale"].AsString); _node.ScaleX = scl.X; _node.ScaleY = scl.Y; } //for sprites the content size is set from the CCSpriteFrame if (dict.ContainsKey("size") && _node.GetType() != typeof(LHSprite)) { _node.ContentSize = CCSize.Parse(dict ["size"].AsString); } if (dict.ContainsKey("generalPosition") && _node.GetType() != typeof(LHUINode) && _node.GetType() != typeof(LHBackUINode) && _node.GetType() != typeof(LHGameWorldNode)) { CCPoint unitPos = CCPoint.Parse(dict ["generalPosition"].AsString); CCPoint pos = LHUtils.positionForNode(_node, unitPos); _node.Position = pos; } // if([dict objectForKey:@"generalPosition"]&& // ![_node isKindOfClass:[LHUINode class]] && // ![_node isKindOfClass:[LHBackUINode class]] && // ![_node isKindOfClass:[LHGameWorldNode class]]) // { // // CGPoint unitPos = [dict pointForKey:@"generalPosition"]; // CGPoint pos = [LHUtils positionForNode:_node // fromUnit:unitPos]; // // NSDictionary* devPositions = [dict objectForKey:@"devicePositions"]; // if(devPositions) // { // // NSString* unitPosStr = [LHUtils devicePosition:devPositions // forSize:LH_SCREEN_RESOLUTION]; // // if(unitPosStr){ // CGPoint unitPos = LHPointFromString(unitPosStr); // pos = [LHUtils positionForNode:_node // fromUnit:unitPos]; // } // } // // [_node setPosition:pos]; // } // if([dict objectForKey:@"anchor"] && // ![_node isKindOfClass:[LHUINode class]] && // ![_node isKindOfClass:[LHBackUINode class]] && // ![_node isKindOfClass:[LHGameWorldNode class]]) // { // CGPoint anchor = [dict pointForKey:@"anchor"]; // anchor.y = 1.0f - anchor.y; // [_node setAnchorPoint:anchor]; // } } }