Skip to content

Commit

Permalink
Fixed all scrolling issues on all devices (woo hoo)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdguru committed Mar 29, 2013
1 parent a7a1cf1 commit add3f13
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
Binary file not shown.
5 changes: 3 additions & 2 deletions RDET2/AWHBaseLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ -(id)initWithDict:(NSDictionary *)layerDict;
AWHSprite *tiledSprite=[[AWHSprite alloc] initWithDict:tiledBackgroundDict];
[self addChild:tiledSprite z:0];

for (int loopVar = 0; loopVar < [scaleManager computeNumHorizTiles:[tiledSprite.mySprite boundingBox].size.width]; loopVar++) {
int numTiles = [scaleManager computeNumHorizTiles:[tiledSprite.mySprite boundingBox].size.width];
for (int loopVar = -1; loopVar < numTiles; loopVar++) {
float x = [scaleManager pointsFromRightBoundary:[tiledSprite.mySprite boundingBox].size.width n:loopVar];
NSMutableDictionary* tileDict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[tiledBackgroundDict objectForKey:@"Name"], @"Name",
Expand All @@ -71,7 +72,7 @@ -(id)initWithDict:(NSDictionary *)layerDict;
nil];

AWHSprite *tile=[[AWHSprite alloc] initWithDict:tileDict];
//NSLog(@"Dict: %@", tileDict);
NSLog(@"Dict: %@", tileDict);
[self addChild:tile z:0];
[tileDict release];
[tile release];
Expand Down
34 changes: 14 additions & 20 deletions RDET2/AWHScaleManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,19 @@ -(float)convertDimension:(NSString*)dim ofSprite:(CCSprite*)sprite{
retval = sprite.position.y/2 - 32;
}
} else if ([dim isEqualToString:@"EScroll"]) {
// First, compute the right side of the leftmost tile
int numTiles = [self computeNumHorizTiles:[sprite boundingBox].size.width];
retval = numTiles*[sprite boundingBox].size.width - screenWidth;
NSLog(@"Numtiles: %d WinWidth %f SpriteWidth: %f Delta %f", numTiles, screenWidth, [sprite boundingBox].size.width, retval);
if (!iPad)
retval = screenWidth + [sprite boundingBox].size.width-retval*2-2;
//retval = screenWidth + [sprite boundingBox].size.width + retval;
int rsideLeftMostTile;
if(!iPad)
{
rsideLeftMostTile = [self pointsFromRightBoundary:[sprite boundingBox].size.width n:numTiles-1] + [sprite boundingBox].size.width/2;
retval = [self pointsFromRightBoundary:[sprite boundingBox].size.width n:-1] - rsideLeftMostTile + [sprite boundingBox].size.width - paddingWidth;
}
else {
retval = screenWidth + [sprite boundingBox].size.width-retval+6;
//retval = screenWidth + [sprite boundingBox].size.width + retval;


rsideLeftMostTile = [self pointsFromRightBoundary:[sprite boundingBox].size.width n:numTiles-1] + [sprite boundingBox].size.width/2;
retval = [self pointsFromRightBoundary:[sprite boundingBox].size.width n:-1] - rsideLeftMostTile + [sprite boundingBox].size.width/2 - paddingWidth/2 -1;
}
//NSLog(@"E-Scroll %f", retval);
NSLog(@"E-Scroll %f", retval);
} else {
// Assume it's a number
retval = [dim floatValue];
Expand All @@ -223,17 +223,11 @@ -(float)computeDurationFromSpeed:(NSString*)speed fromX:(float)fx fromY:(float)f
float speedFloat = [speed floatValue];

// Compute Distance
//CGPoint finish = ccp(x,y);
CGPoint finish;
CGPoint start;
// if(iPad) {
start = ccp(fx,fy);
finish = [self scalePointX:tx andY:ty];
// }
// else {
// start = [self scalePointX:fx andY:fy];
// finish = [self scalePointX:tx andY:ty];
// }
start = ccp(fx,fy);
finish = [self scalePointX:tx andY:ty];

float distance = ccpDistance(start, finish);
//NSLog(@"Speed: %f Distance: %f Duration: %f", speedFloat, distance, distance/speedFloat);
//NSLog(@"Start x:%f y:%f Finish x:%f y:%f", start.x, start.y, finish.x, finish.y);
Expand All @@ -256,7 +250,7 @@ -(int)computeNumHorizTiles:(float)width {
-(float)pointsFromRightBoundary:(float)width n:(int)n {
float retval = screenWidth - width/2-n*width+n+1;
if(iPad)
retval = screenWidth - width/4-n*width/2+n+1;
retval = screenWidth/2 - width/4-n*width/2+n+1;
return retval;
}

Expand Down
4 changes: 3 additions & 1 deletion RDET2/IntroLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ -(void) onEnter

-(void) makeTransition:(ccTime)dt
{
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[AWHGameStateManager scene] withColor:ccWHITE]];
//[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[AWHGameStateManager scene] withColor:ccWHITE]];
CCScene *homeScene = [AWHGameStateManager scene];
[[CCDirector sharedDirector] replaceScene:homeScene];
}
@end
2 changes: 1 addition & 1 deletion RDET2/Resources.plist
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
<string>54</string>
<key>Intervals</key>
<array>
<string>0.15</string>
<string>0.12</string>
<string>0.70</string>
<string>1.05</string>
<string>1.42</string>
Expand Down

0 comments on commit add3f13

Please sign in to comment.