Somehow the code below is throwing a NSInvalidArgumentException, although I followed step by step to make sure everything has proper value...
I have an array of CGPoints stored in NSValues, and this is part of a method to offset all points by (x,y).
for (int i = 0; i < [allPoints count]; i++) {
CGPoint pt = [[allPoints objectAtIndex:i] CGPointValue];
CGPoint newPt = CGPointMake(pt.x + x, pt.y + y);
NSValue *newEntry = [NSValue valueWithCGPoint:newPt];
[allPoints replaceObjectAtIndex:i withObject:newEntry];
}
try this ,
-----------------------------sample code---------------------------------
CGPoint pt =CGPointMake(20, 30);
NSValue *point = [NSValue valueWithCGPoint:pt];
CGPoint pt2 =CGPointMake(40, 40);
NSValue *point2 = [NSValue valueWithCGPoint:pt2];
NSMutableArray *allPoints =[[NSMutableArray alloc]initWithObjects:point,point2, nil];
NSLog(#"%#",allPoints);
// -------------output----------
// "NSPoint: {20, 30}",
// "NSPoint: {40, 40}"
int x=10; int y=20;
for (int i = 0; i < [allPoints count]; i++)
{
CGPoint pt = [[allPoints objectAtIndex:i] CGPointValue];
CGPoint newPt = CGPointMake(pt.x + x, pt.y + y);
NSValue *newEntry = [NSValue valueWithCGPoint:newPt];
[allPoints replaceObjectAtIndex:i withObject:newEntry];
}
NSLog(#"%#",allPoints);
// -------------output----------
// "NSPoint: {30, 50}",
// "NSPoint: {50, 60}"
NSMutableArray method replaceObjectAtIndex:withObject raises an NSInvalidArgumentException if object at given index is nil or new object is nil.
Double check if one of objects in allPoints NSMutableArray is nil.
Or allPoints NSMutableArray doesn't contain NSValue objects with CGPoint elements.
I do not know how, but it seems although I declared allPoints to be NSMutableArray and after a search in my entire code I cannot find in any place where I set the pointer of allPoints to a NSArray, but the system seems to think now that allPoints is now a NSArray and hence I cannot replace any objects.
Therefore I have to circumvent with a new NSMutableArray.
for (int i = 0; i < [allPoints count]; i++) {
CGPoint pt = [[allPoints objectAtIndex:i] CGPointValue];
CGPoint newPt = CGPointMake(pt.x + x, pt.y + y);
NSValue *newEntry = [NSValue valueWithCGPoint:newPt];
NSMutableArray *temp = [NSMutableArray arrayWithArray:allPoints];
[temp replaceObjectAtIndex:i withObject:newEntry];
allPoints = temp;
}
Related
I'm not terribly new to Objective-C, but I can't figure out this issue. I'm attempting to create an instance of a subclass of CCSprite that I made, but it always creates the instance at (0,0), and I can't move it. I've set up my code so that it parses a .txt file in which I put level information, and then it creates sprites based on that information.
Here's the code that initializes the sprite:
-(void)initLevel{
NSLog(#"Level %i is of length %i", lvlNum, [FileReader getLengthOfLevel:[FileReader getStartOfLevel:lvlNum atPath:lvlPack] atPath:lvlPack]);
CCSprite *spriteToMake;
int start = [FileReader getStartOfLevel:lvlNum atPath:lvlPack];
int length = [FileReader getLengthOfLevel:start atPath:lvlPack];
NSString *tmp = [FileReader getLineFromFile:lvlPack byIndex:start];
NSArray *tmpArray = [tmp componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSMutableArray *tmpArray2 = [tmpArray mutableCopy];
[tmpArray2 removeObject:#""];
requiredLinks = [(NSString*)[tmpArray2 objectAtIndex:2] intValue];
[tmpArray2 release];
for(int i = start + 1; i <= start + length; i++){
NSString *line = [FileReader getLineFromFile:lvlPack byIndex:i];
int x = 0;
int y = 0;
NSArray *temp = [line componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSMutableArray *temp2 = [temp mutableCopy];
[temp2 removeObject:#""];
//Determine the type of sprite
if([(NSString*)[temp2 objectAtIndex:0] isEqualToString:#"Basic_Sprite"]){
spriteToMake = [BasicLink sprite];
}else if([(NSString*)[temp2 objectAtIndex:0] isEqualToString:#"Big_Sprite"]){
spriteToMake = [BasicLink spriteWithFile:#"Big_Link.png"];
}else{
spriteToMake = nil;
}
//Create the sprite
if(spriteToMake != nil){
x = [(NSString*)[temp2 objectAtIndex:1] intValue];
y = [(NSString*)[temp2 objectAtIndex:2] intValue];
spriteToMake.position = ccp(x, y);
NSLog(#"%#", spriteToMake);
[self addChild:spriteToMake];
[spriteToMake setUpdate];
}else{
NSLog(#"Sprite set to NULL");
}
NSLog(#"%i, %i, %i", x, y, [temp2 count]);
[temp2 release];
}
}
And here's the subclass' header:
#interface BasicLink : CCSprite{
CGPoint position;
CGPoint movement;
int explosionRadius, width, height;
CCScene *sceneIn;
}
#property (assign)CGPoint pos, movement;
#property (assign)int explosionRadius, width, height;
#property (assign)CCScene* sceneIn;
+(CCSprite*)sprite;
+(CCSprite*)spriteAtX:(int)x atY: (int)y;
-(void)die;
-(void)explode;
-(void)updateSprite;
-(CGRect)getBounds;
-(void)setUpdate;
-(void)move:(int)x, int(y);
#end
And here's the part of the subclass that initializes the sprite:
#implementation BasicLink
#synthesize position, movement, explosionRadius, sceneIn, width, height;
+(CCSprite*)sprite{
return [BasicLink spriteWithFile:#"Basic_Link.png"];
}
Any help is appreciated.
Here's an obvious problem:
-(void)move:(int)x, int(y);
In C, the comma is an operator. The compiler interprets this statement as this method declaration:
- (void)move:(int)x
I'm not entirely certain what it's doing with int(y); it's possibly treating it as a C function declaration. In any case, it isn't part of the method declaration.
Your move declaration should look like this:
- (void)moveToX:(int)x andY:(int)y;
Another minor mistake is the return type of your class methods:
+(CCSprite*)sprite{
return [BasicLink spriteWithFile:#"Basic_Link.png"];
}
That should be:
+ (BasicLink *)sprite{
return [BasicLink spriteWithFile:#"Basic_Link.png"];
}
That's probably not your problem here, though.
I need to return an array but don't know how to do this, here is how it looks
CGPoint position[] = {
CGPointMake(500, 200),
CGPointMake(500, 200)
};
return position;
But I get an error of incompatible result. Any way around this error? Need to return multiple positions.
You can do something like this
NSArray *position = [NSArray arrayWithObjects:
[NSValue valueWithCGPoint:CGPointMake(500, 200)],
[NSValue valueWithCGPoint:CGPointMake(600, 300)],
nil];
for getting the values from array
for(int i=0; i<[position count]; i++) {
NSValue *value = [position objectAtIndex:i];
CGPoint point = [value CGPointValue];
NSLog(#"%#",NSStringFromCGPoint(point);
}
With UIKit Apple added support for CGPoint to NSValue, so you can do:
NSArray *points = [NSArray arrayWithObjects:
[NSValue valueWithCGPoint:CGPointMake(5.5, 6.6)],
[NSValue valueWithCGPoint:CGPointMake(7.7, 8.8)],
nil];
List as many [NSValue] instances as you have CGPoint, and end the list in nil. All objects in this structure are auto-released.
On the flip side, when you're pulling the values out of the array:
NSValue *val = [points objectAtIndex:0];
CGPoint p = [val CGPointValue];
If you don't want to use NSArray and since CGPoint is a struct you can return it the C way
CGPoint *position = malloc(sizeof(CGPoint)*2);
position[0] = CGPointMake(500,200);
position[1] = CGPointMake(500,200);
return position;
although the drawback is that the calling function doesn't know the number of elements in the array, you may need to tell this in some other manner.
also you need to free the returning array once you are done with it using free();
although using NSArray/NSMutableArray is more convenient.
I made an NSMUtableArray of CGpoints and I stored them by subclassing as NSValue, but I cant get the values out. here I what I did.
CGPoint graphPoint;
NSMutableArray *pointValues = [[NSMutableArray alloc] init];
for( int x =0;x<5; x++)
{
NSDictionary* xValue = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:x] forKey:#"X"];
graphPoint.x =x;
graphPoint.y = [CalculatorBrain runProgram: self.graphingPoint usingVariableValues:xValue];
[pointValues addObject:[NSValue valueWithCGPoint:graphPoint]];
}
I tried using this to get the values but I just get null back
for( int x=0; x<5; x++) {
NSValue *val = [pointValues objectAtIndex:x];
CGPoint point = [val CGpointValue];
NSLog(#"Points = %#", point);
}
You can't print a CGPoint using the %# format specifier, as it is not an object. Instead, use NSStringFromCGPoint():
NSLog(#"%#", NSStringFromCGPoint(myPoint));
These are some code that I carried in my project to do matrix computing.
They are two class methods and one instance method that for create matrices and do the matrix multiplication operation.
The method for matrics multiplication doesn't work well, the result from it is wrong.
+ (NSMutableArray *)arrayOfWidth:(NSInteger)width andHeight:(NSInteger)height {
return [[self alloc] initWithWidth:width andHeight:height];
}
- (id)initWithWidth:(NSInteger)width andHeight:(NSInteger)height {
if((self = [self initWithCapacity:height])) {
for(int i = 0; i < height; i++) {
NSMutableArray *inner = [[NSMutableArray alloc] initWithCapacity:width];
[self addObject:inner];
}
}
return self;
}
+ (NSMutableArray *)matrixA:(NSMutableArray *)matrixA multiplyMatrixB:(NSMutableArray *)matrixB {
int aRow = [matrixA count];
int aColumn = [[matrixA objectAtIndex:0] count];
int bRow = [matrixB count];
int bColumn = [[matrixB objectAtIndex:0] count];
NSMutableArray *newArray = [NSMutableArray arrayOfWidth:aRow andHeight:bColumn];
for (int i = 0; i < aRow; i++) {
for (int j = 0; j < bColumn; j++) {
double sum = 0.0;
for (int k = 0; k < aColumn; k++) {
NSMutableArray *innerA = [matrixA objectAtIndex:i];
double numA = [[innerA objectAtIndex:k] doubleValue];
NSMutableArray * innerB = [matrixB objectAtIndex:k];
double numB = [[innerB objectAtIndex:j] doubleValue];
sum += numA * numB;
}
NSNumber *result = [NSNumber numberWithDouble:sum];
[[newArray objectAtIndex:i] insertObject:result atIndex:j];
}
}
return newArray;
}
Is there something wrong with the code?
And how can I fix it?
//First, I create a array to hold the numbers
NSNumber *num11 = [NSNumber numberWithDouble:-2.0];
NSNumber *num12 = [NSNumber numberWithDouble:1.0];
NSNumber *num13 = [NSNumber numberWithDouble:-1.0];
NSNumber *num14 = [NSNumber numberWithDouble:2.0];
NSNumber *num21 = [NSNumber numberWithDouble:-7.0];
NSNumber *num22 = [NSNumber numberWithDouble:0.0];
NSNumber *num23 = [NSNumber numberWithDouble:-1.0];
NSNumber *num24 = [NSNumber numberWithDouble:-4.0];
NSNumber *num31 = [NSNumber numberWithDouble:-2.0];
NSNumber *num32 = [NSNumber numberWithDouble:-1.0];
NSNumber *num33 = [NSNumber numberWithDouble:0.0];
NSNumber *num34 = [NSNumber numberWithDouble:-2.0];
NSNumber *num41 = [NSNumber numberWithDouble:-3.0];
NSNumber *num42 = [NSNumber numberWithDouble:-2.0];
NSNumber *num43 = [NSNumber numberWithDouble:0.0];
NSNumber *num44 = [NSNumber numberWithDouble:-3.0];
NSMutableArray *temp = [NSMutableArray arrayWithObjects:num11, num12, num13, num14, num21, num22, num23, num24, num31, num32, num33, num34, num41, num42, num43, num44, nil];
//Second, I create the matrix and get the elements from that array
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
double c = [[temp objectAtIndex:4*i+j] doubleValue];
NSNumber *object = [NSNumber numberWithDouble:c];
[[matrix objectAtIndex:i] insertObject:object atIndex:j];
}
}
//Then, I do the multiplication for matrix and itself
NSMutableArray *multiMatrix = [NSMutableArray matrixA:matrix multiplyMatrixB:matrix];
//get all the elements from the multiMatrix
double m11 = [[[multiMatrix objectAtIndex:0] objectAtIndex:0] doubleValue];
double m12 = [[[multiMatrix objectAtIndex:0] objectAtIndex:1] doubleValue];
double m13 = [[[multiMatrix objectAtIndex:0] objectAtIndex:2] doubleValue];
double m14 = [[[multiMatrix objectAtIndex:0] objectAtIndex:3] doubleValue];
double m21 = [[[multiMatrix objectAtIndex:1] objectAtIndex:0] doubleValue];
double m22 = [[[multiMatrix objectAtIndex:1] objectAtIndex:1] doubleValue];
double m23 = [[[multiMatrix objectAtIndex:1] objectAtIndex:2] doubleValue];
double m24 = [[[multiMatrix objectAtIndex:1] objectAtIndex:3] doubleValue];
double m31 = [[[multiMatrix objectAtIndex:2] objectAtIndex:0] doubleValue];
double m32 = [[[multiMatrix objectAtIndex:2] objectAtIndex:1] doubleValue];
double m33 = [[[multiMatrix objectAtIndex:2] objectAtIndex:2] doubleValue];
double m34 = [[[multiMatrix objectAtIndex:2] objectAtIndex:3] doubleValue];
double m41 = [[[multiMatrix objectAtIndex:3] objectAtIndex:0] doubleValue];
double m42 = [[[multiMatrix objectAtIndex:3] objectAtIndex:1] doubleValue];
double m43 = [[[multiMatrix objectAtIndex:3] objectAtIndex:2] doubleValue];
double m44 = [[[multiMatrix objectAtIndex:3] objectAtIndex:3] doubleValue];
//Or you can use the NSLog to check the result
NSString *lineOne = [NSString stringWithFormat:#"%f, %f, %f, %f", m11, m12, m13, m14];
NSString *lineTwo= [NSString stringWithFormat:#"%f, %f, %f, %f", m21, m22, m23, m24];
NSString *lineThree = [NSString stringWithFormat:#"%f, %f, %f, %f", m31, m32, m33, m34];
NSString *lineFour = [NSString stringWithFormat:#"%f, %f, %f, %f", m41, m42, m43, m44];
#rooftop, that's all the code
If you're on iOS you might want to consider the matrix routines in GLKit
If you are familiar with MATLAB's vector operations (even if you are not), I would recommend you to check the Accelerate Framework, it is an optimized framework for digital signal processing.
Two great advantages:
They have that operation already implemented.
It's a more efficient way to do it, but apparently not for small matrixes, see the comments for further detail.
This is probably the function you are looking for:
vDSP_mmul: Performs an out-of-place multiplication of two matrices; single precision.
void vDSP_mmul (
float *__vDSP_a,
vDSP_Stride __vDSP_aStride,
float *__vDSP_b,
vDSP_Stride __vDSP_bStride,
float *__vDSP_c,
vDSP_Stride __vDSP_cStride,
vDSP_Length __vDSP_M,
vDSP_Length __vDSP_N,
vDSP_Length __vDSP_P
);
Parameters
__vDSP_a
Input matrix A.
__vDSP_aStride
The stride within __vDSP_a. For example if stride is 2, every second element is used.
__vDSP_b
Input matrix B.
__vDSP_bStride
The stride within __vDSP_b. For example if stride is 2, every second element is used.
__vDSP_c
The result matrix.
__vDSP_M
The number of rows in matrix A.
__vDSP_N
The number of columns in matrix B.
__vDSP_P
The number of columns in matrix A and the number of rows in matrix B.
Discussion
This function multiplies an M-by-P matrix (A) by a P-by-N matrix (B) and stores the results in an M-by-N matrix (C).
This performs the following operation:
On the other side if writing the method yourself is a requirement, this post won't help you at all.
There are mainly two errors here:
In the main program, you did not declare matrix. You know how to fix this problem.
As you create the matrix, if you already initialize the matrix to zeros, insertingObject will make the matrix of size '4x8', and not '4x4'.
[[matrix objectAtIndex:i] insertObject:object atIndex:j];
In your matrix multiplication method, you also insertObject into an existing matrix, making its size '4x8' instead of '4x4'.
To fix this second problem, you need to replace method insertObject:atIndex, with replaceObjectAtIndex:withObject.
That should solve the problem.
A picture is worth a thousand words. Here's mine:
Above depicts two sprites,
the one on the centre right is the player, and the one on the centre left is an AI player.
Both of their initializations use the same superClass. We should see similar quality sprites.
However, as you can see, the right sprite is somehow distorted. I also noticed flecks of other sprites from the same spriteSheet appearing above and below on some animation frames.
No transformations are ever done on the player sprite. No actions other than those also performed on the ai sprites are ever run.
Has anyone else encountered this? I'm not even sure how to phrase this problem ;)
Any more questions? Please ask!
Details:
I'm using Cocos2d 1.0.0.. Xcode 4.1 running on Lion.
Code Samples:
This code is run after the initialization of an NSObject containing CCFiniteTimeActions, and
a CCSprite
NSMutableArray *ww1 = [NSMutableArray array];
for(int i = 0; i <= 3; ++i) {
[ww1 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_left%d.png", string, i]]];
}
CCAnimation* aa1 = [CCAnimation animationWithFrames:ww1 delay:0.1f];
walkLeft = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:aa1 restoreOriginalFrame:NO]];
//RIGHT
NSMutableArray *walkAnimFrames = [NSMutableArray array];
for(int i = 0; i <= 3; ++i) {
[walkAnimFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_right%d.png", string, i]]];
}
CCAnimation *aa2 = [CCAnimation animationWithFrames:walkAnimFrames delay:0.1f];
walkRight = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:aa2 restoreOriginalFrame:NO]];
//UP
NSMutableArray* ww2 = [NSMutableArray array];
for(int i = 0; i <= 3; ++i) {
[ww2 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_up%d.png", string, i]]];
}
CCAnimation* aa3 = [CCAnimation animationWithFrames:ww2 delay:0.1f];
walkUp = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:aa3 restoreOriginalFrame:NO]];
//DOWN
//walkAnimFrames = nil;
//walkAnimation = nil;
NSMutableArray* ww3 = [NSMutableArray array];
for(int i = 0; i <= 3; ++i) {
[ww3 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_down%d.png", string, i]]];
}
CCAnimation* aa4 = [CCAnimation animationWithFrames:ww3 delay:0.1f];
walkDown = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:aa4 restoreOriginalFrame:NO]];
//ATTACK ANIMATIONS
animation = [CCSprite spriteWithSpriteFrameName:[NSString stringWithFormat:#"%#_down0.png", string] ];
NSMutableArray* ww4 = [NSMutableArray array];
for(int i = 0; i <= 3; ++i) {
[ww4 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_left_attack%d.png", string, i]]];
}
CCAnimation *qq0 = [CCAnimation animationWithFrames:ww4 delay:0.1f];
meleeLeft =
[CCAnimate actionWithDuration:0.4 animation:qq0 restoreOriginalFrame:NO];
//RIGHT
NSMutableArray* ww5 = [NSMutableArray array];
for(int i = 0; i <= 3; ++i) {
[ww5 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_right_attack%d.png", string, i]]];
}
CCAnimation *qq1 = [CCAnimation animationWithFrames:ww5 delay:0.1f];
meleeRight =
[CCAnimate actionWithDuration:0.4 animation:qq1 restoreOriginalFrame:NO];
//UP
NSMutableArray* ww6 = [NSMutableArray array];
for(int i = 0; i <= 3; ++i) {
[ww6 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_up_attack%d.png", string, i]]];
}
CCAnimation *qq2 = [CCAnimation animationWithFrames:ww6 delay:0.1f];
meleeUp =
[CCAnimate actionWithDuration:0.4 animation:qq2 restoreOriginalFrame:NO];
//DOWN
NSMutableArray* ww7 = [NSMutableArray array];
for(int i = 0; i <= 3; ++i) {
[ww7 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_down_attack%d.png", string, i]]];
}
CCAnimation *qq3 = [CCAnimation animationWithFrames:ww7 delay:0.1f];
meleeDown =
[CCAnimate actionWithDuration:0.4 animation:qq3 restoreOriginalFrame:NO];
//****DEATH ANIMATIONS
NSMutableArray* ww8 = [NSMutableArray array];
for(int i = 0; i <= 7; ++i) {
[ww8 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_left_die%d.png", string, i]]];
}
CCAnimation *qq4 = [CCAnimation animationWithFrames:ww8 delay:0.05f];
deathLeft =
[CCAnimate actionWithDuration:0.4 animation:qq4 restoreOriginalFrame:NO];
//RIGHT
NSMutableArray* ww9 = [NSMutableArray array];
for(int i = 0; i <= 7; ++i) {
[ww9 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_right_die%d.png", string, i]]];
}
CCAnimation *qq5 = [CCAnimation animationWithFrames:ww9 delay:0.05f];
deathRight =
[CCAnimate actionWithDuration:0.4 animation:qq5 restoreOriginalFrame:NO];
//UP
NSMutableArray* ww10 = [NSMutableArray array];
for(int i = 0; i <= 7; ++i) {
[ww10 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_up_die%d.png", string, i]]];
}
CCAnimation *qq6 = [CCAnimation animationWithFrames:ww10 delay:0.05f];
deathUp =
[CCAnimate actionWithDuration:0.4 animation:qq6 restoreOriginalFrame:NO];
//DOWN
NSMutableArray* ww11 = [NSMutableArray array];
for(int i = 0; i <= 7; ++i) {
[ww11 addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:#"%#_down_die%d.png", string, i]]];
}
CCAnimation *qq7 = [CCAnimation animationWithFrames:ww11 delay:0.05f];
deathDown =
[CCAnimate actionWithDuration:0.4 animation:qq7 restoreOriginalFrame:NO];
[sprites addChild:animation];
[walkRight retain];
[walkLeft retain];
[walkUp retain];
[walkDown retain];
[meleeDown retain];
[meleeUp retain];
[meleeLeft retain];
[meleeRight retain];
[deathUp retain];
[deathRight retain];
[deathDown retain];
[deathLeft retain];
[self setDir:newFacing];
the variable "sprites" is a pointer to a CCSpriteBatchNode. I am certain they point to the same batch node, as there is only one.
As you can see, this object adds its own animation to the layer via batch node.
I'll post the method where the movement occurs:
moveAction = [CCMoveTo actionWithDuration:0.3 position:ccp(thisDoodad.newX, thisDoodad.newY)];
if (thisDoodad.animation.visible == NO) {
id beingVisible = [CCCallFunc actionWithTarget:thisDoodad
selector:#selector(makeVisible)];
id seq = [CCSequence actions: moveAction, beingVisible, nil];
[thisDoodad.animation runAction:seq];
} else {
[thisDoodad.animation runAction:moveAction];
}
Since the time of asking, I have tried adding the line:
[[animation texture] setAliasTexParameters];
It rid the player's sprite of the blur, but stretched the image slightly wide.
It's probably worth mentioning that each of these sprite frames are 32x32 pix, and do not fill the entire frame.
Additionally, the above line of code did not affect the appearance of the ai's sprites.
* ------- *
Edit::
I fixed it.
What happened:
I have two floats which hold the location the sprite is about to move to on screen.
All other sprites in my world are drawn from the player's reference.
During my referencing, the float was formatted into an int, so every other sprite in the game received the int version of the position.
This leads me to believe, somewhere in my code there must be something that fractionalizes these two floats.
Thanks #jtbandes for the "half pixel value" hint. I still do not know how the position became anything but an integer though :(
Anyways, changing the floats to ints fixed everything.
Thanks!
Perhaps the position of the sprite is aligned to a half-pixel value, such as 150.5 pixels. This could cause the visual distortion/blurring.