Explosion animation on Hit Sprite Kit [closed] - objective-c

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I wonder how to make add one explosion animation to my game when my character/Ship is hit by an enemy? I've managed to add explosion sound but I want to add a image aswell to the hit on my character, wondering how?
if ([_ship intersectsNode:asteroid]) {
asteroid.hidden = YES;
SKAction *blink = [SKAction sequence:#[[SKAction fadeOutWithDuration:0.1],
[SKAction fadeInWithDuration:0.1]]];
SKAction *blinkForTime = [SKAction repeatAction:blink count:4];
SKAction *shipExplosionSound =
[SKAction playSoundFileNamed:#"explosion_large.caf" waitForCompletion:NO];
[_ship runAction:[SKAction sequence:#[shipExplosionSound,blinkForTime]]];
_lives--;
NSLog(#"your ship has been hit!");
}

To achieve an explosion effect you should use a Particle Emitter Editor bundled with Xcode and a SKEmitterNode.
A particle emitter special effect begins with an image file that is to represent the particle. The emitter is then responsible for generating multiple instances of the particle on the scene and animating each particle subject to a set of properties. These properties control aspects of the special effect such as the rate of particle generation, the angle and speed of motion of particles, whether or not particles rotate and the way in which the particles blend in with the background.
With some time and experimentation, a wide range of special effects ranging from smoke to explosions can be created using particle emitters.
Source:
http://www.techotopia.com/index.php/An_iOS_7_Sprite_Kit_Particle_Emitter_Tutorial
I managed to achieve a really good looking explosion effects in my apps using SKEmitterNode and playing with the values in the editor.
Hope it helps.

Related

How to remove a grey shadow from a JPEG? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
So in Photoshop we all know it's relatively easy to remove a white background from a .jpg image if the contrast is quite visible.
The problem with this image though is it has a grey shadow at the bottom of the image that is reliant on the white background, and therefore once it becomes transparent the shadow looks nasty.
What would be the best approach to remove this once the white background had been removed?
Thanks
https://s15.postimg.org/k2itasu7v/i_Stock_104502239_LARGE.jpg
You can use the Polygonal Lasso Tool. Manual removing.
Zoom to the shadow, select it with the Polygonal Lasso Tool > Right click and : Refine the edge + give it a bit of Feather and paint using the background color of the image.

Is there a way to "clipToBounds" Particles within a UIView in Xcode?

I've done some searching and haven't run across someone trying to accomplish this yet. I have a particle emitter within a small UIView and I would like to keep the particles from leaving the UIView. So for example, when a particle approaches the border of the view, it would "slide-under" and disappear. Currently the particles fly out of the UIView border and into the surrounding views. If this isn't clear, I can try to clarify any questions you may have. Thank you.
-PS: Another possible solution would be to have the particles "bounce" off the UIView boundary, if this is a possibility.
Here is an image of what I'm trying to do:

Move background relative to an object [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
This is a Processing 2.x related question but you can give a general answer and I will translate that into processing sketch.
I want to move my background relative to an object that i have made in box2d and is following a trajectile path. I want that object to remain inside the sketch and not to go past the width of the sketch. how can I do that?
This is what I have tried: (The image displayed is a large image, 4 times the width of the sketch)
void Display(Gulli gulli) {
imageMode(CENTER);
if (gulli.isMoving()) {
Vec2 gulli_pos = gulli.getPosition();
gulli_pos.mulLocal(-1); // to move background in opposite direction of the object
pushMatrix();
translate(gulli_pos.x+width*1.63, +height/2+gulli_pos.y);
image(img, pos.x, pos.y);
popMatrix();
} else {
pushMatrix();
translate(width*1.5, -height/2);
image(img, pos.x, pos.y);
popMatrix();
}
}
I did something like that ones, let me try to explain it whit this simple drawing.
The black square is the background image, the grey one the sketch screen of Processing and the red ball your moving object.
The idea it's that while the distance between the side of the backImage and the side of the screen is greater than 0, you move the background image using the same speed than the ball, but in the opposite direction. Ones this condition changes you move the ball normally.
Hope this help's.
Regards
Jose

Create Image programmatically in Objective-C [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to know is it is possible to create a blank image programmatically in Objective-C (Mac osx)? My requirement is I want to create a watermark, so one source image is there.. But i need to create an another image and add some text to that image and bind the second image with the first one so that it will display as a watermark. Is it is possible to create an image like that? i know how to merge two images. I don't know how to create an image programmatically and add some text on it.
You can create a blank png using:
// The NO here is the opaque parameter. You can set it to YES according to your needs.
UIGraphicsBeginImageContextWithOptions(CGSizeMake(150, 150), NO, 0.0);
UIImage *blankImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
u can create image like this, hope this helps u ..
NSImage *blackImage = [[NSImage alloc]initWithSize:NSMakeSize(22, 12)];
[blackImage lockFocus];
NSColor *blackColor=[[NSColor blackColor]autorelease];
[blackColor set];
NSRectFill(NSMakeRect(0, 0, 22, 12));
[blackImage unlockFocus];
[item setImage:[blackImage autorelease]];//now you can get the black image hear item is imageView this is without ARC code u can remove autorelease if u want

iOS: "Flip-Clock" animation - how to? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
currently I´m working on an App where I like to implement a nice "flip-clock"-animation for numbers (like this: http://www.youtube.com/watch?v=dKhsn-qrEZY).
It is realy hard to find a resource for an animation like this one I´m looking for. One of the best I found was this one: http://www.voyce.com/index.php/2010/04/10/creating-an-ipad-flip-clock-with-core-animation/
But I´m not very trusted with CoreAnimation. So it is hard to dive into the article I found.
The article didnt describe all pieces in detail. As consequence (for me ;))the problem is that I have no idea where I have to start...
Did anyone know a good article / resource / place where I can find a better explained solution for such an animation?
Or can someone help me to understand this article better?
Thank you!
You can apply a 3D transform on a UIView layer to rotate about any of the axis (or combination)...
CATransform3DMakeRotation(<#CGFloat angle#>, <#CGFloat x#>, <#CGFloat y#>, <#CGFloat z#>)
This will rotate the view it is applied to by the angle (given in radians).. specify either 0 or 1 for the x, y and z values to decided whether or not to apply the angle rotation to that axis.
Now of course you can animate this transform by creating a normal UIVIew beginAnimations block, setting the transform and commiting the animation block.
To set the transform, use [myView.layer setTransform:myTransform];