animation made in adobe flash professional - android

I have made 2 different animations in Adobe flash professional cs5.5 for an Android aplication.
And I want a code that makes it possible for a user of the app to play the animation as often they want, so if the user wants the animation to play 1 time the first animation will be playes, if the user wants to play it 2 times the animation 1 and 2 will be played, if the user wants the animation 3 times played the animation 1, 2 and 1 will be played and so on.
Can somebody help me with this problem and tell me if this is possible in jquery.

If I was you, the way I would approach this is by having a keyframe after each of the animations where you can type some code.
On the menu page or where ever you have the code for how many times the code should run, define a variable and call it something like "runTimes" which should become the amount of times the animation should run.
At the end of the animations do a simple if statement to check what the value of "runTimes" is and then decrement it. Depending on the value, it should use gotoAndPlay/gotoAndStop.
So, put this on the keyframe after the first animation:
if (runTimes > 0) {
runTimes--;
gotoAndPlay(<FIRST FRAME OF SECOND ANIMATION>);
} else {
gotoAndStop(<FRAME OF MAIN MENU>);
}
and this after the second animation:
if (runTimes > 0) {
runTimes--;
gotoAndPlay(<FIRST FRAME OF FIRST ANIMATION>);
} else {
gotoAndStop(<FRAME OF MAIN MENU>);
}
On the mainmenu frame, let's assume you have a textbox named "numTimes_txt" for the number of times to play and a button "playAnimations_btn" to start the animations.
import flash.events.MouseEvent;
var runTimes:int = 0;
playAnimations_btn.addEventListener(MouseEvent.CLICK, playAnims);
function playAnims(e:MouseEvent):void {
runTimes = parseInt(numTimes_txt.text);
play(); // or gotoAndPlay(<FIRST FRAME OF FIRST ANIMATION>);
}
I haven't tested this as I don't have my IDE on me right now, but this should work if I understand the question properly.

Related

How to make a game object appear through triggers from 3 different game objects

I am developing an AR app using Unity3D and Vuforia.
I did all the basics of AR and now in the process of completing it.
However, I am currently stuck at the triggers part.
I have 3 flashcards (Number 1, Number 2, Plus). I have put box colliders in each one of them and rigidbodies in Number 1 and Number 2. The Plus card acts as the trigger.
Right now, I am trying to make the game objects in each card disappear when triggered, and a fourth game object will appear when the trigger happens. The fourth game object is the result of the addition (i.e. 1 + 2 = 3).
I have developed the following code. The game objects are triggered according to the tags I have given them. The game objects disappear, but the fourth game object doesn't appear. What have I done wrong here?
#pragma strict
var mathplus : GameObject;
var sphere01 : GameObject;
var sphere02 : GameObject;
var result03 : GameObject;
function Start(){
sphere01.SetActive(true);
sphere02.SetActive(true);
mathplus.SetActive(true);
result03.SetActive(false);
}
function OnTriggerEnter (other : Collider) {
Debug.Log("Object entered the trigger.");
if (other.tag == "number01" && other.tag == "number02"){
mathplus.SetActive(false);
sphere01.SetActive(false);
sphere02.SetActive(false);
result03.SetActive(true);
}
}
function OnTriggerExit (other : Collider) {
Debug.Log("Object exited the trigger.");
mathplus.SetActive(true);
sphere01.SetActive(true);
sphere02.SetActive(true);
result03.SetActive(false);
}
The game objects in the Number cards are called "sphere", the game objects in the Plus card is called "mathplus", and the fourth game object is called "result03".
I hope someone can help rectify this problem.
Thanks and regards.
You made a small mistake.
It is because the fourth card is disabled, so the collider of it is disabled too.
Your logic is right, what you should do is invisible the card4, not disable it
Disable Mesh Rendering To Hide A Gameobject
GetComponent(MeshRenderer).enabled = false;
It is c# script, sorry, I do not know very about unity js.😆
You can get more detail from invisible Gameobject and disable Gameobject

Android Studio Libgdx Animation

I am trying to do an animation whenever my character jumps. It works in the following way: when I jump, I first draw the animation of my char. If it is finished, I start modifying his position and also draw another texture, for the inAir moment. The problem is that the animation runs instantly (I tried putting the speed 1 frame per second,but it still runs instantly) and the character jumps before the animation is done. I suspect it considers it finished before it actually finishes. This is how I check if the animation is finished: first I check if the animation start (the jump button is pressed) and then I have an if condition like this:
if (animationStarted && rightJumpAnim.isAnimationFinished(System.currentTimeMillis()))
{
animationStarted = false;
animationFinished = true;
timePassed1 = 0;
}
After this, I put animationFinished to false when he touches the ground again. Any advice?
P.S. here is the code for running the jumpAnimation:
if (toDrawJumpRight1 == true) {
animationStarted = true;
timePassed1 += Gdx.graphics.getDeltaTime();
spriteBatch.draw(rightJumpAnim.getKeyFrame(timePassed1, false), posX + cameraX, posY + cameraY, sizeX, sizeY);
}
Your problem should be in the very first line you provided to us:
if (animationStarted && rightJumpAnim.isAnimationFinished(System.currentTimeMillis()))
The argument you must pass is the STATETIME of the animation.
if (animationStarted && rightJumpAnim.isAnimationFinished(timePassed1))
Edit:
Some more Informations to this problem:
You say you want 1 frame stay 1 Second.
Now we say, you have approx 5 frames.
5frames * 1 second = 5seconds for finish
so if statetime is over 5 seconds, your animation is played ONE time (is finished)
Animation.isAnimationFinished(float stateTime) checks now, if the current stateTime from your animation is higher than the 5 seconds.
System.currentTimeMillis is at this moment:
1440618906341
now.. whats bigger?
Have a nice Evening (I recommend using TimeUtils.millis instead of System.currentTimeMillis, guess it's optimated, fo' sure.)

Detaching all instances of a sprite AndEngine

I'm building a tank game using AndEngine that has multiple levels, but I'm not using multiple scenes, I'm sticking to 1 Main Game Scene that should reset and modify itself when the user beats the level.
I'm able to successfully modify the scene, but I'm having an issue with removing the enemies. There are multiple instances of an enemy sprite that the user has to kill, but when the user successfully completes the requirement to advance a level(killing x number of enemies), the enemies aren't reset; the instances from the previous level haven't been removed from the screen.
As a result, when a user is on Level 2, there might still be 3 or 4 enemies roaming around from Level 1 that the user didn't need to kill.
I tried using detachChild to remove the enemy from the screen and attachChild to instantly add them back, but when the next level started, the enemies wouldn't spawn.
How can I remove all instances of the enemy sprite that are currently on the screen without affecting the spawning?
when you are starting the game you have to create different layers(Entities) like gameLayer,
background Layer, HUD Layer... .So that you can update the items based on the situation.
This process make you unload resources smoothly when level is completed.
Coming to your requirement ... add every sprite instance to array list when it is created.
Remove all these as follows
public static void removeSprites(List<Sprite> spriteList, IEntity scene){
for(int i = spriteList.size() - 1; i >= 0; i--) {
final Sprite sprite = spriteList.get(i);
scene.detachChild(sprite);
spriteList.remove(i);
}
spriteList = null;
System.gc();
}
you must also unload Texture Atlases in your game
Well, try to use this method: sprite.detachchildren()

Unable to stop CSS3 transition of transform by translate3d

I'm trying to animate an element by CSS3 transtions using translate3d: JSFiddle.
// for start animation
$("#content")
.css("-webkit-transition", "all 100s");
.css("-webkit-transform", "translate(0, -900px)");
// for stop animation
$("#content")
.css("-webkit-transition", "none");
In desktop Chrome and Safari is good, but in the default browser on Android 4.1.x (SGSII, Galaxy Nexus, etc) this approach does not work - transition does not stop. Additionally, I note that the situation is only a relatively translate3d: with translate and position CSS props (e.g. "top", "left") it works.
The transition implementation on Android 4 seems to be buggy in cases where a transitioning hardware-rendered layer is canceled by adjusting the webkitTransitionDuration to 0 (and setting webkitTransition to 'none' or '' often implies this). This can be circumvented by using a transition duration of .001ms or similar, although this very likely still draws multiple frames.
A more practical work-around on at least certain devices is to use a negative value for the webkitTransitionDelay, forcing a new transition to take effect, but choosing this value such that the transition starts directly in its finished state.
Like so:
e.style.webkitTransition = '-webkit-transform linear 10s';
e.style.webkitTransform = 'translate3d(100px,100px,0)';
# now cancel 10s-long transition in 1s and reset transformation
setTimeout(function() {
e.style.webkitTransitionDelay = '-10s'
e.style.webkitTransform = 'translate3d(0,0,0)';
}, 1000)
Here is what I discovered with some experimentation:
Stopping a running translate2d or 3d on chrome, safari, firefox, and iphone webview can be done by setting a transition of "none" or a transition with a negative or 0 time delay and giving a new translation to the current position as described above.
This however does not work for android webview. The only solution I could find for android was to set the transition delay to a small positive number like .001s and giving a translate for the current position.
Note that in iphone webview the solution of a negative transition delay is preferable to "none" or a small positive number which will flash the final position of the ongoing transition before performing the preempting following transition.
This solves my (very similar) problem:
$el.removeClass('THE_ANIMATION').css('opacity', 0.99);
window.setTimeout(function () {
$el.css('opacity', 1);
}, 0);

label over label overwriting , while displaying the health lable in cocos2d android

I have to display the palyers lifes in my game. every time the player hits the wrong enemy the lifes decrease.the default lifes are 5.
My code is as follows
first I declare this in my gamelayer
static int lifes=5;
CCLabel _lifes;
then a method as follows at bottom of the code
public void showLable(CCLabel _lifes){
if(_lifes != null){
this.removeChild(_lifes,true);
}
_lifes = CCLabel.makeLabel("" + lifes, "Verdana", 20);
_lifes.setColor(ccColor3B.ccbrown);
_lifes.setPosition(winSize.width/2,(winSize.height/2));
addChild(_lifes,3)
}
then I wrote this condition where the player hits the wrong enemy
lifes--;
showLable(_lifes);
1) everything works fine, the lable is displayed and label gets decreased but the label does not show up until the player hits the wrong enemy, as you see I gave default value as 5, the label shows up after the player hits wrong enemy ie, from 4.
2) Another major problem is the label displayed is displaying without removing the previous value. For ex. the lifes are 5 as default. 5 is displayed when when game starts. when the life decreases the lifes value should be 4, So here in my game the 4 is placed on 5 itself.
And then the lifes are placed on the same number as 3 or 2 or 1. All the nuumbers show on each other. Now I think you understand me
thanks in advance
1) check that your are calling showLable(_lifes); at the start of your game after its initialized, so the label show up with the value 5.
2) I'm not really sure about it but CCLabel should extends a CCSprite and thus have a setVisible method.
you may try something like :
if(_lifes != null){
_lifes.setVisible(false);
this.removeChild(_lifes,true);
}
I only found the c++ api reference version :
http://www.cocos2d-x.org/reference/native-cpp/d4/de7/classcocos2d_1_1_c_c_sprite.html

Categories

Resources