I am using the CCAnimation class for using animation with more than one CCSprite . What I want is :
" Just Remove the sprite after the animation complete "
If anybody work on this, Please Let me Know. What should I do for it.
I know the solution of pktangyue works but I want to add a new answer because this is deprecated in cocos2d-x V3.x Please read the final way to do this it's more easy
Node *nodeSprite =(Node*)layer->getChildByName("BFL_Ready_Label");
MoveTo* animation = MoveTo::create(1.0f,Point(Director::getInstance()->getWinSize().width/2,Director::getInstance()->getWinSize().height*1.5));
CallFunc* animationDone = CallFunc::create(bind(&Node::removeFromParent,nodeSprite));
Sequence* sequence = Sequence::create(animation,animation,NULL);
node->runAction(Sequence);
And like the previous answer using a Sprite.
MoveTo* animation = MoveTo::create(1.0f,Point(Director::getInstance()->getWinSize().width/2,Director::getInstance()->getWinSize().height*1.5));
CallFunc::create(bind(&Sprite::removeFromParent,m_sprite));
Sequence* sequence = Sequence::create(animation,animation,NULL);
m_sprite->runAction(sequence);
Using this the compiler will not tell that you're using deprecated methods. I hope this will useful.
I update this answer because there's a much easy way to do this
when you create a sequence just add the RemoveSelf::create RemoveSelf it's an action so you can add it to the sequence it will destroy the sprite or Node after the animation is complete.
Sequence* sequence = Sequence::create(animation,animation,RemoveSelf::Create(),NULL);
And that's the easy way to destroy the object after
the animation is completed this is very usefull in particles
Suppose m_action is your animation and m_sprite is you sprite node.
Then you can create a CCSequence action, with a CCCallFunc action in the final, like the following code:
CCSequence* seq = CCSequence::create(action,
CCCallFunc::create(m_sprite, callfunc_selector(CCSprite::removeFromParent),
NULL);
m_sprite->runAction(seq);
sprite_name->runAction(Sequence::create(ScaleTo::create(1, 0),RemoveSelf::create(), NULL));
Related
I am working on vb project in visual studio 2015.I need to animate the text "Darkode" from left to right.
I tried the following code which i pulled from the internet,
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:.8" Storyboard.TargetProperty="Left" From="1920" To="0" AccelerationRatio=".1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
But i didn't understand it Correctly? I need more clarification on the topic.
I had encountered a similar situation where i had to Animate my logo. After searching for hours in the internet i found a solution which was not very useful to me but given your situation (animate a text from left to right) ,it will be more useful to you.
Here is the code :
Private Sub trmText_Timer()
If lblCaption.Caption <> StrCap Then
lblCaption.Caption = Left(StrCap, Len(lblCaption.Caption) + 1)
Else
lblCaption.Caption = ""
End If
End Sub
Here is the source for the code:http://www.setha.info/ict-visualbasic6/72-ict-vb6-0013.html
Here is the link for my qusetion :Animation of words in visual studio
Explanation
Unlike the code you posted in your question which uses storyboard for animation the above code uses Timer control for animation.
In the above code StrCap contains your text darkode and
lblCaption.Caption is an empty string onto which you iterativly put you text charater by charater on each iteration.
Heres a link if you want to know more about timer control :Timer Control
Is it possible to focus and open up the information just like we do on click using magnet in cardboard android?
Like ray gaze in unity, is there a alternative for android?
I want to do something like the one shown in chromeexperiments
Finally solved!
In treasurehunt sample, you can find isLookingAtObject() method which detects where user is looking...
And another method called onNewFrame which performs some action in each frame...
My solution for our problem is:
in onNewFrame method I've added this snippet code:
if (isLookingAtObject()) {
selecting++; // selecting is an integer defined as a field with zero value!
} else {
selecting = 0;
}
if (selecting == 100) {
startYourFunction(); // edit it on your own
selecting = 0;
}
}
So when user gazes 100 frame at object, your function calls and if user's gaze finishes before selecting reaches 100, selecting will reset to zero.
Hope that this also works for you
Hope this helps. (Did small research, (fingers crossed) whether the link shared below directly answers your question)
You could check GazeInputModule.cs from GoogleSamples for
Cardboard-Unity from Github. As the documentation of that class says:
This script provides an implemention of Unity's BaseInputModule
class, so that Canvas-based UI elements (_uGUI_) can be selected by
looking at them and pulling the trigger or touching the screen.
This uses the player's gaze and the magnet trigger as a raycast
generator.
Please check some tutorial regarding Google Cardboard Unity here
Please check Google-Samples posted in Github here
Hi I'm developing a game by using andengine.I have a player in my game created with TiledSprite.Also there box2d physic engine.Here is the porblem: Player is moving ahead.But a while later there is a wall on his top and if he wanna continue to go ahead, he has to incline.Incline method just make "player.setCurrentTileIndex(12);". So player image is getting small(incline position).Till here everything is right.But playerBody isn't getting small.That's why he still can't pass the wall by inclining.How can I solve it?
You can understand the problem with photos better:
In this picture, he can't go in there:
http://t1310.hizliresim.com/1g/j/tmpyd.png
In this picture, he can go in there but he can't:
http://j1310.hizliresim.com/1g/j/tmpz2.png
I searched this stutation and found this: destroy the fixture and create new one. But I need this solution with code examples. I couldn't get it well.
You have to create new body for it everytime.
I have 2 MyGameScreen objects that extends cocos2d::CCLayer. I am capturing the ccTouchesMove of the first screen so that I can create the moving effect exactly like sliding between pages of iOS application screen.
My class is like so:
class MyGameScreen: public cocos2d::CCLayer {
cocos2d::CCLayer* m_pNextScreen;
}
bool MyGameScreen::init() {
m_pNextScreen = MyOtherScreen::create();
}
void MyGameScreen::ccTouchesMoved(CCSet *touches, CCEvent *event){
// it crashes here... on the setPosition... m_pNextScreen is valid pointer though I am not sure that MyOtherScreen::create() is all I need to do...
m_pNextScreen->setPosition( CCPointMake( (fMoveTo - (2*fScreenHalfWidth)), 0.0f ) );
}
EDIT: adding clear question
It crashed when I try to setPosition on m_pNextScreen...
I have no idea why it crashed as m_pNextScreen is a valid pointer and is properly initialized. Could anybody explain why?
EDIT: adding progress report
I remodelled the whole system and make a class CContainerLayer : public cocos2d::CCLayer that contains both MyGameScreen and MyOtherScreen side by side. However, this looked like not an efficient approach, as when it grows I may need to have more than 2 pages scrollable side by side, I'd prefer to load the next page only when it is needed rather than the entire CContainerLayer that contains all the upcoming pages whether the user will scroll there or not... Do you have any better idea or github open source sample that does this?
Thank you very much for your input!
Use paging enable scrollview.download files from following link and place in your cocos2d/extenision/gui/ after that you have to set property of scrollview to enablepaging true with paging view size.
https://github.com/shauket/paging-scrollview
For Scene Transitions you can do this:
void MyGameScreen::ccTouchesMoved(CCSet *touches, CCEvent *event)
{
CCScene* MyOtherScene = CCTransitionFadeUp::create(0.2f, MyOtherScreen::scene());
CCDirector::sharedDirector()->replaceScene(MyOtherScene);
}
I have started using Andengine, and after following some tutorials I'm starting to develope for myself.
Right now I have a a BaseGameActivity where I call one splashScene(working fine) and after that my MenuScene.
If i set a simple background (just color) it loads fine (all menu text are displayed), but when i try to set a repeating sprite as background, a black screen appears (no error show in logcat)
I'm using the example code for the background
super(BaseActivity.getSharedInstance().mCamera);
activity = BaseActivity.getSharedInstance();
RepeatingSpriteBackground mGrassBackground = new RepeatingSpriteBackground(mCamera.getWidth(), mCamera.getHeight(), activity.getTextureManager(), AssetBitmapTextureAtlasSource.create(activity.getAssets(), "images/menu/background.png"), activity.getVertexBufferObjectManager());
this.setBackground(mGrassBackground);
I placed this code in the MenuScene constructor.
Thanks in advance and sorry for my English
I just discover my problem.
The code was right the problem was in the image format, it has to be a power of two (it says that clearly in the source code comments)
Next time I will try to read carefully before asking