Settings screen in Cocos2D game - uiviewcontroller

How are settings screens created in Cocos2D games?
I've considered using a UIViewController subclass however pushing it in Cocos2D seems hacky. I've also considered using a CCLayer with buttons etc as child nodes. Then I could animate this layer in/out when appropriate. Is this the common way?

If you are using Cocos2D for your game, you should probably get in the habit of building your settings screens as Cocos2D scenes or layers, which offers the benefit of easily animating them into and out of the frame during your game. Adding a view controller is not necessary and actually complicates things when it is so easy to just create a CCScene or CCLayer.
I prefer the CCLayer approach, then I can animate the layer swooshing into the frame when a user presses a Settings button. The underlying game play is not erased since it is the same scene.
Another approach is to pop a settings scene onto the current scene.

Related

8-direction Figure Animation with Arrow Keys

I've been charged with designing a demo for an isometric video game in ActionScript 3. I have the bitmap spritesheets that show the avatar I'm using standing and walking in each direction. The walking animation is made up of three frames.
My problem, though, is that I need to figure out how to make use of them. I'm not familiar with animation in Flash, and I need input on how to gotoAndPlay() the walking frames for the right direction. I don't think isolating the necessary DIRECTION is going to be a challenge, so much as starting it and keeping it going while the arrow keys are down.
My current code is basically comprised of keyboard handlers for KEY_UP and KEY_DOWN, each containing a switch-case statement that changes the Avatar.currentDirection property. The handler continues to fire while the keys are down, but I need to add animation to the game.
I've seen some examples where they simply embed the animations into an SWF, propagate an array of the various walking stages, and alternate between them using an EnterFrame event handler, but this seems really clunky. I guess in the end I'm trying to make use of Adobe Animate, but I don't know how you're supposed to do that.
Ops, fortunately i'm working with sprites (atlas animations) right now!.
if i'm right, you just needs to use them for playing some animation with functionality.
if you have a well sized sprite which is tiled with isometric slots like it:
(9 frames sized 64x128)
your work is very easy, only create new movieclip from library, inside it, create a borderless rectangle (which is our mask) in a layer (named mask) then import image to the project, and its better to disabling smooth ability from image properties,
now, inside your movieclip, you have to create new layer (under the mask layer) and add your sprite image for each frame, and change its position:
at last, enable masking for mask layer, then its time of coding,
name your animation queries (like image 3) and for loopable animations, insert gotoAndPlay('anim_name') inside last frame. i hope you are familiar with controling movieclip animations which is basic consept of any flash project.
now to extend it for 8 directions support, you just need to play and switch between dirctions according single and multi keypreses,

Possible to Drive Object Properties with Motion Tween?

I'm trying to create a complex parallax effect in Flash video sequence that includes translation and scaling among many layers.
I've been looking for a way to set up my scene to where I could just animate one object (preferably with motion tween) and then apply some percentage of that animation to each background object (or flip values accordingly).
Is there any way to harvest Motion Tween data out of a layer of a MovieClip and translate that into x,y values for objects? [So far I've only created instances of objects and set their positions through actionscript.]
Seems like you need to use a copy motion option of the layer context menu
Also tweening actionscript libraries e.g. TweenMax are capable of tweening any properties of any objects, but they do it with actionscript (which can be easily copied/modified/pasted), not Adobe Flash UI.
So converting every visual element to a movieclip allowed me to position the items in Z as well. That pretty much solved my problem.
Thanks everyone.

AS3 - What are the different methods of rendering animation on the screen?

I'm a beginner to AS3 and programming in general, but have learned enough that I want to now start learning how to render animations on the screen. These are the methods that I know of from two days of "researching" on google.
I'm not in a situation where I could afford to take courses from an educational institution, so my only means of learning are through online sources.
Update an objects x or y positions in a loop on every frame. Very basic. Of course any kind of advanced animation (say, showing a character running) is not possible with this method alone.
Using Flash and creating animation on a movie clip's timeline and, combined with moving the position of the object we can achieve some proper animation this way. However I cannot afford Flash, so this is not an option available to me. It also doesn't seem to be a popular option among more experienced programmers either (I think, due to having poor performance when lots of objects animating on the screen?)
Using a sprite sheet and then blitting the relevant image from the sprite sheet onto the screen.
Is there any other way to put an image from a sprite sheet onto the screen other than blitting?
And what other methods of rendering animation are available?
Some online websites claim that blitting is all I'll ever need, but I want to know all the options available so I could choose the most appropriate one for any given situation.
Any help would be appreciated :)
Another option for blitting is Stage3D. Take a look at Starling for 2D animations.
Blitting would be my best opinion. The only other thing I can think of is manually taking the images from the sprite sheet and putting it into each frame of an animation.
To render animation, you can create a frame in a MovieClip and convert it into a MovieClip and name the frame 'running'. Then you need to create an Enter Frame event where the MovieClip's instance name is 'Guy' and in the code on the function write 'Guy.x += 5;' to make your MovieClip go 5 pixels to the right every frame and also in the function write "Guy.gotoAndStop('running');"
Use TweenMax engine for better animation purposes. Easy coding, more Animation!!

How to structure code/frames in Flash

I'm working on a Flash game where there are scenes that display a few stages of animation; the animation is controlled by user-clickable buttons (1 through 4) and a progress bar which increases by some amount with a timer.
Right now I have each stage of the animation on a different frame, but I'm not sure how to share the Actionscript and state (e.g. value of the progress var) across the frames.
Should I consolidate these frames into one and let each piece (the buttons, progress bar, and animation) all be three separate movie clips that are controlled by the actionscript of that frame? Or is there another way to do this properly?
What you said is probably the best solution in this case: put everything on one frame and control with ActionScript. The buttons can be their own MovieClips (or Buttons), the progress bar and animation as well. You can then have each stage of the animation on a different frame within the MovieClip, and control which frame appears when using gotoAndStop().
Generally I only use the base frames (i.e. those at the root of an SWF) as animation frames if the SWF is purely animation with no or minimal ActionScript involved. In any other case (games, applications, etc) it's always better to have animations in their own MovieClips, so that you can control and manipulate them easily.

Adding multiple children to the stage

I'm a new flash developer. I have read here http://www.flashandmath.com/intermediate/children/stage.html that I should avoid adding children to the stage itself and only add them to my MainTimeLine derived main document class (which is itself a child of stage). However, the author does not give explanation/justification for this approach.
I am developing a project where I am considering adding UI popup windows to the stage directly rather than including them in my MainTimeline (it makes it easier to keep them above everything else and also makes it easier for me to know what I need to persist and what I don't when saving).
What are the downsides of this? Is it a "bad practice" in Flash? Why?
For quick demos and presentations I often use the Flash IDE's timeline to manage my depths. I create empty movieClips and put them on the different layers. For example, my top layer would be my Popup Layer, under that would be my Main Content Layer, under that would be my Background Layer. My main document class manages the adding and removing of popups, content and background instances.
I believe it is bad practice to add children directly to the Stage. Here is a decent thread explaining some differences between MainTimeLine vs stage.