turning Fire Animation to actionscript 3 - actionscript

How can I turn Fire animation from Timeline to ActionScript 3 Code?
If I use fire animation on timeline for my game, characters position and level details would reset.
Do you have any advice about how can I handle this issue?
My experience on flash is too low, sorry for this kind of question
Thanks

Make a Fire movieclip that contains all the fire timepline animation. Then simply call it's play() function to play it.

Related

Pausing one animation while keeping another — BAFluidView Swift

Okay...this is a long shot. Here's goes...
Background:
For a long time, I've been trying to figure out how to animate a wave horizontally across the screen while a long press is active. When the long press is interrupted or ends, the wave pauses in place, while continuing to ripple.
I've struggled to find a way to implement this. And then I recently stumbled across BAFluidView. I was able to get the wave looking as I'd like it to:
The wave animates nicely. I can control when it starts. But, I can't pause it's motion across the screen while allowing the actual wave to continue.
About me:
I'm new to this.
I don't know much (almost none) Objective-C
The library was written in Objective-C
My ask:
Does anyone see a way for me to pause this damn wave?
If not here, what am I missing that could make this so much easier?
Here's a link to the repo containing BAFluidView's code.
And here's a link to the wave shown below. It's not the app I'm working on, but it's an attempt to figure out how to pause this wave.
Thanks!
I think pause animation is not possible but you remove current on going animation with below method.
[myView.layer removeAllAnimations];
Try WaveAnimationView instead. It is written in Swift and you can set the progress to any value between 0.0-1.0.
In case of animating the process of increasing or decreasing the progress of an instance of WaveAnimationView, I use a repeat timer, which looks like
Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { Timer in
if wave.progress == *yourvalue*{
Timer.invalidate()
return}
wave.progress += 0.01
}
Or you can try UIView.animate() method, which I didn't experiment though.

using NSTimer to move objects on screen

I am building a simple ios gaming app where I have to move a few objects on screen, and these moving objects react to swipe gestures and change their direction based on that. I am not using spritekit or any other gaming framework for this, and the way I am moving the objects is by triggering an NSTimer that fires 60 times a second. I am not using any threads explicitly so I guess the timer is executed by the main thread ? The code block that the timer triggers updates the location of objects based on their speed (defined as pixels per time unit in x/y direction). It is working fine and I am almost at the end of my project, but while testing the app I've realized that although the movement of objects seem pretty good most of the times, however sometimes the movement is a little rough/patchy.
My question is that is it the right way to do something like this, how can I improve the performance ? will using something like GCD can help with the issue of jittery movement ? (I haven't looked into GCD in detail but I am willing to spend time on it if I know that will help)
Thanks for any help !
and the way I am moving the objects is by triggering an NSTimer that fires 60 times a second
I would recommend not doing that. Various forms of animation are built in (View animation, Layer animation, CADisplayLink, UIKit Dynamics), and of course there's always Sprite Kit. Use the tools you are given for this purpose. Don't reinvent the unicycle when you already have a Ducati at your disposal.

is there any way to detect an object is falling or get the speed/direction on axis-y in cocos2d?

I'm a newbie to Cocos2d and game development. Now I'm encountering a problem.
I have a figure and I want to add different animations to it such as jump and fall. For the jump it is fine because I will have a button to trigger jump and I can add animation to it. However, for falling down is another story:
At the beginning, I'm trying to use - (void) update() and it seems this method is for constant moving. Another attempt is try to add a callback for CCAction. However, this can only detect falling after jump.
I'm wondering is there an API to detect an object is falling, or get the speed/direction on axis-Y. Or I have to do it manually and listen frame by frame?
I really appreciate your help =)

How to successfully pause game in Corona SDK?

Im trying to learn Corona through someone else's sample code. So this is a game like fruit ninja, and im trying to put a pause/resume function on it. Now since the code uses physics, i thought that i should use physics.pause and physics.start and i also paused the timer for the objects. It does freezes the screen, but when you swipe at one of the objects on the screen(fruits), it still breaks into two. How do i stop that? So i guess the pause works a little, because it stops the fruits from coming up. Thanks so much for the people who will answer my question. Ive read a few forums on here and you guys seem to really know what youre doing. :)
From your line here:
Runtime:addEventListener("touch", drawSlashLine)
Is it possible to remove this event listener in your pause, and re-add it into your resume?
Actually that will just stop you from drawing. You need to loop through all objects and remove their touch event listener.
Alternatively set a global variable to true when paused, and in chopFruit function check it, and do nothing if its set to true.
You should add code similar to the following:
if gameIsActive then
gameIsActive = false
physics.pause()
Runtime:removeEventListener("enterFrame",moveEnemy)
leftarrow:removeEventListener( "touch", moveLeft )
end
Then on resume, you should add the event listeners back.

Trouble toggling the userInteractionEnabled property in iOS

I am developing a tic tac toe game for iOS and I am using a combination of UIButtons and UIImageViews to allow for user interaction and to display the moves made. My problem is that the buttons continue to accept user input before the cpu makes it's move, which breaks my game logic. I have made several attempts to toggle the userInteractionEnabled property, but I have only been able to turn it off. The engine that gets everything started in the game is my buttonPressed method. I also toggle the userInteractionEnabled property within this method and therein lies my problem: How do I re-enable the property after disabling user interaction? Is there a method that is called in between events that I can overwrite?
I have searched the web and I have searched through the developer documentation provided by Apple and I found information on the touchesBegan and touchesEnded methods. However, from what I understand, those methods need to be explicitly called which brings me back to my original problem of not being able to call those functions without the user's interaction.
If anyone can help, I would greatly appreciate it! I have been racking my brain over this for the past couple of weeks and I am just not seeing a solution.
I'd think that for a game like tic-tac-toe, calculating the countermove should be so fast that it can be done immediately in response to the first button press. If you're doing something complicated to calculate the next move, like kicking off a thread, you might want to reconsider that.
Let's say, though, that your game is something like chess or go, where coming up with a countermove might take a bit longer. Your view controller should have a method to make a move for the current player, let's call it -makeMove:. Your -buttonPressed action should call that method to make a move for the user. In response, -makeMove: should update the state of the game, switch the current player to the next player. If the new current player is the computer, it should then disable the controls and start the process of calculating the next move. Let's imagine that's done by invoking some NSOperation, so that coming up with the next move is an asynchronous task. Once the operation has come up with a move, it should again invoke -makeMove: (by calling -performSelectorOnMainThread:), which will again update the game state and the current player. This time, though, it should see that the new current player is not the computer, and so it should re-enable the controls.

Resources