How do I draw a new image without making a new UIImageView - iphone

I have a character in an iPod Touch game I am making that moves around the screen. That I have under control... However I want him able to shoot fireballs, and I don't want to have to make a new UIImageView for every fire ball he shoots. I have the image and everything... I think i need to use quartz core or openGL ES, but I can't make sense of the apple documentation.

Another option would be to implement drawRect in your view, and draw the fireballs there.

Related

Scrolling Scene Background - Unity

My title might have actually been a bit misworded, as to be honest I'm not sure how to word it, but basically I'm making a game on Unity and I have my main scene and I am making a main menu however what I want to do is have a, I guess, camera slowly panning around the main scene as the background of the main menu. Not sure if I worded that right or what wording to actually type into Google to research it so I'm hoping you guys might be able to point me in the right direction.
Cheers guys,
Jason
As stromdotcom mentioned you can attach a script to the camera.
It's hard to tell what you're trying to do but if you want to circle the camera around a point...
Try making an empty game object in the middle of your scene and point the camera at it.
Make the object the parent of the camera (using the object and cameras transform properties).
From here you should be able to set the game object to rotate using a script, which should make the camera spin as it is a child of the object.
I have not tried this in Unity but I have used this technique in other programs so I'm assuming it will work. Sorry if it doesn't.
If your scene is already set up then you can attach a script to your camera which simply modifies the camera's transform to move it around the room. You can move and rotate the camera just like any other transform in your scene.
Im pretty sure what you are looking for is "Animation view". Unity has a tutorial on it: https://unity3d.com/learn/tutorials/topics/animation/animation-view?playlist=17099

iOS - rotating a sphere and responding to touch

I've been tasked with creating a sphere that can be rotated by touch (or animated) along one axis, like a regular globe. I should also be able to draw animated lines on this sphere (eg. draw a line between Sydney and New York). I usually do all my animations in 2D, typically using core animation as I've never really had a need to do anything else. I have a feeling that this sort of problem though requires me to jump into OpenGL.
My question is whether it would be possible to achieve this using core animation (time is of the essence), or if I do need to quickly learn OpenGL. If so, is this a fairly simple problem to solve? I'm a pretty good programmer, but I have no OpenGL experience. Would a capable programmer be able to do this in say 2 weeks?
As a further question, supposing I do use OpenGL, if I then need to do other things in the project (eg. show different screens, or show screens over the top of the sphere), am I able to use UIKit or does the entire project need to be in OpenGL?
Core Animation is for animating views, and basically a 2D animation layer - so it's a no-go for the 3D rotating sphere.
Drawing a textured sphere is rather easy, see this sample
Mixing GL and regular UIView's is not a problem. You can overlay regular controls over the GL view.

How do I add background in cocos2d?

I'm a total noob. Starting my first app. I'm using cocos2d and there's isn't a .xib file so how do I add a background image behind the sprites I have in my scene?
In Cocos2d you don't use xibs you have to place all the objects by code. Check the samples that come with Cocos2d to get a sense of how it works.
If you already know how to add sprites, adding a background is done the same way, it would be just another sprite just add it with a lower z-order.
[self addChild:myBackground z:0];
"self" would be the actual CCLayer
"myBackground" the sprite you created with the bakcground iamge.
and "z" would have to be lower than the z used for the other elements.

Playing 3D Animation in iPhone App (Possibly using a looping video)

Is there a relatively easy was to include a 3D animation into an iPhone app? We have the animations already made up for another project and our client has asked if they can be placed inside an iPhone app. We could perhaps include a low-res looping video of the animation (it's just a 3D component rotating on a single axis), or would it be better to look into getting the 3D animation directly onto a view?
Cheers,
Dan
You could either split it up into a set of frames and use the UIView animationImages property like so:
http://appsamuck.com/day2.html
Or assuming its already an OpenGL animation you could port the code to openGLES.
Here are good tutorials for openGL ES:
http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html

Why is manually moving a UIImageView slow?

I am trying to write a head-to-head iPhone Air Hockey (like) game. When the user touches the screen I move the "puck" by placing the UIImageView center where the touch center is.
Also I move the puck (another UIImageView) using a timer. This method is slow and shaky. I know I can get performance out of OpenGL ES but I do not want it to get that involved if I can help it.
I would also like to take advantage of the animation engine for special effects and such. How can I manually move the paddles and puck to a timer and get better performance. Or do I just have to embrace OpenGL ES for this?
Or do I just have to embrace the OpenGL?
No there is a middle ground: CoreAnimation.
Matt Gallagher has a demo game (for Mac) which uses Core Animation to display sprites. You will not see the same performance on iPhone as desktop but, your game is much simpler than his example.