So I am trying to create a game. The most similar one I could find on the app store is Tasty Planet.
So mostly what I have so far is an NSTimer that starts this every 3 seconds:
it randomly emits images from right to left. I also have, image2, which is controlled by tilting.
I want to be able to tell when they cross.
I've tried using:
if (CGRectIntersectsRect(image2.frame, image1.frame)){
image1.hidden = YES;
image2.transform = CGAffineTransformScale(image2.transform, 1.2 , 1.2);
}else {
}
But it wont work.
I think the problem is because the timer creates a whole new image.
Is the a better way to do what I am trying to do so far.
I think, you may want to do like this (if it's wrong, so sorry).
Explaining about this way in English, is difficult for me, and code become too long. but did like this, can move obj without animation block.
When intersect, small view is changed background color, rewrite this part.
Use UIView class, rewrite your need class.
I think, you may want to do like this (if it's wrong, so sorry).
Explaining about this way in English, is difficult for me, and code become too long. but did like this, can move obj without animation block.
When intersect, small view is changed background color, rewrite this part.
Use UIView class, rewrite your need class.
Thank you so much for doing all this. Is there anyway to make it be an image, instead of squares?
Thanks!
sure, UIView's "Ball"class need to rewrite UIImageView class.
<.h part>
@interface Ball : UIImageView
<.m part>
1: "initWithFrame:" method,
- (id)initWithFrameCGRect)rect {
self = [super initWithFrame:rect];
self.image = [UIImage imageNamed:@"yourImage.png"]; (jpg is also OK)
}
>>Add "self.image" in code.
2: for() in "moveObj:"method.
for (UIImageView *obj in self.superview.subviews)
>>UIView rewrite to UIImageView.
*: optionally, if you need,(on initWithFrame
self.contentMode = UIViewContentModeScaleToFill;
Once again thanks for doing all this. One last thing. I need to check if it intersects with an image that is in my other view.
I dont know how to do this because it is undeclared.
if your view is UIImageView class, this loops is not need to change.
But if your view is other class (UILabel, UIButton, UIView...etc), UIImageView should rewrite to UIView (or id).
if your view is UIImageView class, this loops is not need to change.
But if your view is other class (UILabel, UIButton, UIView...etc), UIImageView should rewrite to UIView (or id).
4:
if([obj respondToSelector(methodOfYourClass)]) {
// if the instance can respond your method.
}
you should think which way is better, or other way is more better.
Ok, I've been working with this. Now I need to change the view after 3 intersections.
I've tried using:
[self.delegate gameViewControllerDidFinish:self];
but every time it ends up crashing. I have no idea why.
Ok, I've been working with this. Now I need to change the view after 3 intersections.
I've tried using:
[self.delegate gameViewControllerDidFinish:self];
but every time it ends up crashing. I have no idea why.
...gameViewControllerDidFinish & delegate? No build failed?
Do you get this error message?
"request for member 'delegate' in something not a structure or union"