Exemplo n.º 1
0
void AniTest::runThisTest()
{
    Director::getInstance()->replaceScene(this);
    initAni();
    
    // Add Touch Listener
    auto dispatcher = Director::getInstance()->getEventDispatcher();
    
    auto touchListener = EventListenerTouchOneByOne::create();
    touchListener->onTouchBegan = [=](Touch* touch, Event* event){
        
        m_armature->stopAllActions();
        Point touchPoint = touch->getLocation();
        Point heroPoint = m_armature->getPosition();
        
        Point deltaPoint = touchPoint - heroPoint;
        
        float time = sqrt(deltaPoint.x * deltaPoint.x + deltaPoint.y * deltaPoint.y) * 0.002;
        ActionInterval *action = cocos2d::MoveBy::create(time, deltaPoint);
        FiniteTimeAction *actionCallBack = CallFuncN::create(CC_CALLBACK_1(AniTest::setNormal, this));
        m_armature->runAction(Sequence::create(action, actionCallBack, NULL));
        setRun();
        
        if(deltaPoint.x < 0){
            m_armature->setRotation3D(Vertex3F(0, 180, 0));
        }else
        {
            m_armature->setRotation3D(Vertex3F(0, 0, 0));
        }
        return true;
    };

    
    dispatcher->addEventListenerWithSceneGraphPriority(touchListener, this);
}
Exemplo n.º 2
0
bool BigExplosion::init(){
    auto part1_frame=SpriteFrameCache::getInstance()->getSpriteFrameByName("toonSmoke.png");
    ValueMap vm1=ParticleManager::getInstance()->GetPlistData("toonSmoke");
    part1 = ParticleSystemQuad::create(vm1,part1_frame);
    this->addChild(part1);
    auto part2_frame=SpriteFrameCache::getInstance()->getSpriteFrameByName("toonGlow.png");
    ValueMap vm2=ParticleManager::getInstance()->GetPlistData("glow");
    part2 = ParticleSystemQuad::create(vm2,part2_frame);
    this->addChild(part2);
    auto part3_frame=SpriteFrameCache::getInstance()->getSpriteFrameByName("toonFlare2.png");
    ValueMap vm3=ParticleManager::getInstance()->GetPlistData("debris");
    part3 = ParticleSystemQuad::create(vm3,part3_frame);
    this->addChild(part3);
    part1->setTotalParticles(10);
    part1->setEmissionRate(9999999999);
    part2->setTotalParticles(3);
    part2->setEmissionRate(9999999999);
    part3->setTotalParticles(20);
    part3->setEmissionRate(9999999999);
    part3->setScale(1.5);
    part1->setRotation3D(Vertex3F(30,0,0));
    part2->setRotation3D(Vertex3F(30,0,0));
    part3->setRotation3D(Vertex3F(30,0,0));
    return true;
}
void Boss::_dash()
{
    int neg = (CCRANDOM_0_1()>0.5)? -1: 1;
    
    auto array = PointArray::create(6);
    
    array->addControlPoint(Point(0,0));
    array->addControlPoint(Point(80*neg,-300));
    array->addControlPoint(Point(500*neg,-900));
    array->addControlPoint(Point(700*neg,-600));
    array->addControlPoint(Point(500*neg,400));
    array->addControlPoint(Point(0,0));
    
    auto action = CardinalSplineBy::create(5.5, array,0);
    runAction(Sequence::create(
                               DelayTime::create(0.5),
                               EaseSineOut::create(action)
                               ,nullptr)
              );
    runAction(
              Sequence::create(
                               EaseSineInOut::create(RotateBy::create(0.5, Vertex3F(0,30*neg,0))),
                               RotateBy::create(2.5, Vertex3F(-30,45*neg,-90*neg)),
                                RotateBy::create(1, Vertex3F(0,-35*neg,-200*neg)),
                               EaseSineInOut::create(RotateBy::create(1.5, Vertex3F(30,-40*neg,-70*neg))),
                               CallFunc::create(this, Boss::_next()),
              nullptr)
              );
}
Exemplo n.º 4
0
void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode)
{
    _batchNode = spriteBatchNode; // weak reference

    // self render
    if( ! _batchNode ) {
        _atlasIndex = INDEX_NOT_INITIALIZED;
        setTextureAtlas(nullptr);
        _recursiveDirty = false;
        setDirty(false);

        float x1 = _offsetPosition.x;
        float y1 = _offsetPosition.y;
        float x2 = x1 + _rect.size.width;
        float y2 = y1 + _rect.size.height;
        _quad.bl.vertices = Vertex3F( x1, y1, 0 );
        _quad.br.vertices = Vertex3F( x2, y1, 0 );
        _quad.tl.vertices = Vertex3F( x1, y2, 0 );
        _quad.tr.vertices = Vertex3F( x2, y2, 0 );

    } else {

        // using batch
        kmMat4Identity(&_transformToBatch);
        setTextureAtlas(_batchNode->getTextureAtlas()); // weak ref
    }
}
Exemplo n.º 5
0
void Skin::draw()
{
    // If it is not visible, or one of its ancestors is not visible, then do nothing:
    if( !_visible)
    {
        _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vertex3F(0, 0, 0);
    }
    else
    {
        //
        // calculate the Quad based on the Affine Matrix
        //

        Size size = _rect.size;

        float x1 = _offsetPosition.x;
        float y1 = _offsetPosition.y;

        float x2 = x1 + size.width;
        float y2 = y1 + size.height;

        float x = _transform.tx;
        float y = _transform.ty;

        float cr = _transform.a;
        float sr = _transform.b;
        float cr2 = _transform.d;
        float sr2 = -_transform.c;
        float ax = x1 * cr - y1 * sr2 + x;
        float ay = x1 * sr + y1 * cr2 + y;

        float bx = x2 * cr - y1 * sr2 + x;
        float by = x2 * sr + y1 * cr2 + y;

        float cx = x2 * cr - y2 * sr2 + x;
        float cy = x2 * sr + y2 * cr2 + y;

        float dx = x1 * cr - y2 * sr2 + x;
        float dy = x1 * sr + y2 * cr2 + y;

        _quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
        _quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
        _quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
        _quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
    }

    // MARMALADE CHANGE: ADDED CHECK FOR NULL, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
    if (_textureAtlas)
    {
        _textureAtlas->updateQuad(&_quad, _textureAtlas->getTotalQuads());
    }
}
Exemplo n.º 6
0
void SmallExplosion::createExplosion(Node* _effectLayer, Point pos){
    
    part1->setTotalParticles(8);
    part1->setEmissionRate(9999999999);
    part1->setScale(0.7);
    part2->setTotalParticles(5);
    part2->setEmissionRate(9999999999);
    _effectLayer->addChild(this,7);
    part1->setRotation3D(Vertex3F(30,0,0));
    part2->setRotation3D(Vertex3F(30,0,0));
    this->setPosition(pos);
    this->scheduleOnce(schedule_selector(SmallExplosion::recycle), 1.5);
}
bool Plane::init(){
	
    _Model = Sprite3D::create("playerv002.obj", "playerv002_256.png");
    if(_Model){
        _Model->setScale(55);
        ((Sprite3D*)_Model)->setOutline(0.035, Color3B::BLACK);
        _Model->setRotation3D(Vertex3F(originX,originY,originZ));
        this->setRotation3D(Vertex3F(originX, originY, originZ));
        this->addChild(_Model);
        this->scheduleUpdate();
    }
    return true;
}
void BigDude::die(){
    CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("boom2.mp3");
    this->_alive = false;
    EnemyController::enemies.eraseObject(this);
    EnemyController::showCaseEnemies.pushBack(this);
    EffectManager::createExplosion(getPosition());
    Point nowPoint = this->getPosition();
    log("now X: %f Y:%f \n",nowPoint.x,nowPoint.y);
    Point targetPos = Point(nowPoint.x,nowPoint.y-200);
    log("now X: %f Y:%f \n",targetPos.x,targetPos.y);
    unscheduleAllSelectors();
    this->runAction(
                     Sequence::create(
                                      Spawn::create(
                                                    EaseSineOut::create(MoveTo::create(2, targetPos)),
                                                    EaseSineOut::create(ScaleTo::create(2,0.3)),//TODO: replace with move 3d when possible
                                                    //EaseBackOut::create(RotateBy::create(2,Vertex3F(CC_RADIANS_TO_DEGREES((nowPoint-targetPos).getAngle()),CC_RADIANS_TO_DEGREES((nowPoint-targetPos).getAngle())+45,-CC_RADIANS_TO_DEGREES((nowPoint-targetPos).getAngle())+90))),
                                                    RotateBy::create(2, Vertex3F(360+CCRANDOM_0_1()*600, 360+CCRANDOM_0_1()*600, 360+CCRANDOM_0_1()*600)),
                                                    nullptr
                                                    ),
                                      CallFunc::create(this,callfunc_selector(BigDude::fall)),
                                      nullptr
                                      ));


}
Exemplo n.º 9
0
bool Missile::init()
{
    _Model = Sprite3D::create("daodanv001.obj", "daodan_32.png");
    if(_Model)
    {
        addChild(_Model);
        _radius=10;
        _type = kPlayerMissiles;
        _Model->setScale(3);
        _Model->setRotation3D(Vertex3F(90,0,0));
        _damage = 75;
        static_cast<Sprite3D*>(_Model)->setOutline(0.3, Color3B(0,0,0));
        
        _left = (CCRANDOM_MINUS1_1()>0);
        if(_left)
            _yRotSpeed *= -1;
        
        
        // missile effects

        
        auto part2 = ParticleSystemQuad::create("emission.plist");
        addChild(part2);
        part2->setPosition(0,-34);
        part2->setPositionType(tPositionType::GROUPED);
        //part2->setScale(2.5);
        auto part1 = ParticleSystemQuad::create("missileFlare.plist");
        addChild(part1);
        part1->setPosition(0,-30);
        part1->setPositionType(tPositionType::GROUPED);
        part1->setScale(2.5);
        return true;
    }
    return false;
}
Exemplo n.º 10
0
Vertex3F Node::getRotation3D() const
{
    // rotation Z is decomposed in 2 to simulate Skew for Flash animations
    CCASSERT(_rotationZ_X == _rotationZ_Y, "_rotationZ_X != _rotationZ_Y");

    return Vertex3F(_rotationX,_rotationY,_rotationZ_X);
}
Exemplo n.º 11
0
void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimmedSize)
{
    _rectRotated = rotated;

    setContentSize(untrimmedSize);
    setVertexRect(rect);
    setTextureCoords(rect);

    Point relativeOffset = _unflippedOffsetPositionFromCenter;

    // issue #732
    if (_flippedX)
    {
        relativeOffset.x = -relativeOffset.x;
    }
    if (_flippedY)
    {
        relativeOffset.y = -relativeOffset.y;
    }

    _offsetPosition.x = relativeOffset.x + (_contentSize.width - _rect.size.width) / 2;
    _offsetPosition.y = relativeOffset.y + (_contentSize.height - _rect.size.height) / 2;

    // rendering using batch node
    if (_batchNode)
    {
        // update dirty_, don't update recursiveDirty_
        setDirty(true);
    }
    else
    {
        // self rendering
        
        // Atlas: Vertex
        float x1 = 0 + _offsetPosition.x;
        float y1 = 0 + _offsetPosition.y;
        float x2 = x1 + _rect.size.width;
        float y2 = y1 + _rect.size.height;

        // Don't update Z.
        _quad.bl.vertices = Vertex3F(x1, y1, 0);
        _quad.br.vertices = Vertex3F(x2, y1, 0);
        _quad.tl.vertices = Vertex3F(x1, y2, 0);
        _quad.tr.vertices = Vertex3F(x2, y2, 0);
    }
}
bool Boss::init(){
    _score = 666;
    _Model = Sprite3D::create("boss.obj", "boss.png");
    //auto cannon2 = Sprite3D::create("bossCannon.obj", "boos.png");
    if(_Model)
    {
        
        _Model->setScale(28);
        addChild(_Model);
        _Model->setRotation3D(Vertex3F(90,0,0));
        static_cast<Sprite3D*>(_Model)->setOutline(0.1, Color3B(0,0,0));
        _type = kEnemyBoss;
        _HP = 5000;
        _radius = 150;
        auto cannon1 = Sprite3D::create("bossCannon.obj", "boss.png");
        _Cannon1 = Node::create();
        addChild(_Cannon1);
        _Cannon1->addChild(cannon1);
        cannon1->setScale(28);
        cannon1->setRotation3D(Vertex3F(90,0,0));
        _Cannon1->setPosition3D(Vertex3F(40,-100, 10));
        cannon1->setOutline(0.1, Color3B(0,0,0));
        
        auto cannon2 = Sprite3D::create("bossCannon.obj", "boss.png");
        _Cannon2 = Node::create();
        addChild(_Cannon2);
        _Cannon2->addChild(cannon2);
        cannon2->setScale(28);
        cannon2->setRotation3D(Vertex3F(90,0,0));
        _Cannon2->setPosition3D(Vertex3F(-40,-100, 10));
        cannon2->setOutline(0.1, Color3B(0,0,0));
        //addChild(_Cannon2);
        //_Cannon2->setPosition(-20,-200);
        
        _Cannon1->setRotation(-45);
        _Cannon2->setRotation(45);
        
                enterTheBattle();
        return true;
    }
    return false;
}
Exemplo n.º 13
0
void BulletExplosion::showExplosion(Point point){
    auto animation = AnimationCache::getInstance()->getAnimation("bullet_expl");
    auto animate = Animate::create(animation);
    this->runAction(Sequence::create(animate,
                                     CallFuncN::create(CC_CALLBACK_1(BulletExplosion::explosionFinished,this)),                                  NULL));
    this->setScale(0.5);
    this->runAction(ScaleBy::create(0.4, 2));
    this->runAction(FadeOut::create(0.4));
    this->setPosition(point);
    this->setRotation3D(Vertex3F(30,0,0));
    this->setBlendFunc(BlendFunc::ADDITIVE);
    Director::getInstance()->getRunningScene()->getChildByTag(100)->getChildByTag(123)->addChild(this,3);
}
Exemplo n.º 14
0
void LayerColor::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
{
    _customCommand.init(_globalZOrder);
    _customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this, transform, transformUpdated);
    renderer->addCommand(&_customCommand);
    
    for(int i = 0; i < 4; ++i)
    {
        kmVec3 pos;
        pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _positionZ;
        kmVec3TransformCoord(&pos, &pos, &_modelViewTransform);
        _noMVPVertices[i] = Vertex3F(pos.x,pos.y,pos.z);
    }
}
void Boss::enterTheBattle()
{
    setRotation3D(Vertex3F(100,0,0));
    setScale(0.2);
    runAction(
              Sequence::create(
                               Spawn::create(
                                             EaseSineOut::create(MoveTo::create(4, Point(0,300))),
                                             EaseSineOut::create(ScaleTo::create(4,1)),//TODO: replace with move 3d when possible
                                             EaseBackOut::create(RotateBy::create(4+0.5,Vertex3F(-100,0,0))),
                                             nullptr
                                             ),                                             CallFunc::create(this, callfunc_selector(Boss::startShooting)),
                               CallFunc::create(this, callfunc_selector(Boss::_turns)),
                               nullptr
                               ));
}
Exemplo n.º 16
0
bool FodderLeader::init()
{
    _Model = Sprite3D::create("dijiyuanv001.obj", "dijiyuanv001.png");
    if(_Model)
    {
        _Model->setScale(8);
        addChild(_Model);
        _Model->setRotation3D(Vertex3F(90,0,0));
        static_cast<Sprite3D*>(_Model)->setOutline(0.2, Color3B(255,0,0));
        _type = kEnemyFodderL;
        _HP = 20;
        _radius = 35;
        return true;
    }
    return false;
}
Exemplo n.º 17
0
bool BigDude::init()
{
    _Model = Sprite3D::create("diji1_v002.obj", "diji02_v002_128.png");
    if(_Model)
    {
        _Model->setScale(8);
        addChild(_Model);
        _Model->setRotation3D(Vertex3F(90,0,0));
        static_cast<Sprite3D*>(_Model)->setOutline(0.2, Color3B(0,0,0));
        _type = kEnemyBigDude;
        _HP = 50;
        _radius = 40;
        
        
        return true;
    }
    return false;
}
Exemplo n.º 18
0
void Missile::update(float dt)
{
    if(!_target)
    {
        //setTarget(static_cast<GameLayer*>(getParent())->_testDummy);//very hacky
        setTarget(static_cast<GameEntity*>(EnemyController::enemies.getRandomObject()));
    }
    if(_target){
        //turn towards the target
        float angle = -CC_RADIANS_TO_DEGREES((getPosition() - _target->getPosition()).getAngle());
        if(fabsf(angle-90)>70)
        {
            //too much angle to track, get another target instead
            _target = nullptr;
        }
        float curRot = getRotation();
        float angleDif = std::min(std::max((angle-90) - curRot, -_turnRate*dt), _turnRate*dt);
        
        float f = curRot + angleDif;
        setRotation(f);
        setPosition(getPosition()+Point(sinf(CC_DEGREES_TO_RADIANS(f))*_velocity,cosf(CC_DEGREES_TO_RADIANS(f))*_velocity) + _vector*dt);
        _vector = _vector * (1-dt);
        
    }
    else{
        float f = getRotation();
        setRotation(f);
        setPosition(getPosition()+Point(sinf(CC_DEGREES_TO_RADIANS(f))*_velocity,cosf(CC_DEGREES_TO_RADIANS(f))*_velocity) + _vector*dt);
        _vector = _vector * (1-dt*0.5);
    }
    // missiles need to rotate
    _yRotation += _yRotSpeed*dt;
    _Model->setRotation3D(Vertex3F(90,_yRotation, 0));
    
    _velocity += _accel*dt;
}
Exemplo n.º 19
0
Vertex3F Vertex3F::operator/(const float& f) const { return Vertex3F(p / f, n / f, c / f); }
Exemplo n.º 20
0
void Sprite::updateTransform(void)
{
    CCASSERT(_batchNode, "updateTransform is only valid when Sprite is being rendered using an SpriteBatchNode");

    // recalculate matrix only if it is dirty
    if( isDirty() ) {

        // If it is not visible, or one of its ancestors is not visible, then do nothing:
        if( !_visible || ( _parent && _parent != _batchNode && static_cast<Sprite*>(_parent)->_shouldBeHidden) )
        {
            _quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vertex3F(0,0,0);
            _shouldBeHidden = true;
        }
        else
        {
            _shouldBeHidden = false;

            if( ! _parent || _parent == _batchNode )
            {
                _transformToBatch = getNodeToParentTransform();
            }
            else
            {
                CCASSERT( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
                kmMat4 nodeToParent = getNodeToParentTransform();
                kmMat4 parentTransform = static_cast<Sprite*>(_parent)->_transformToBatch;
                kmMat4Multiply(&_transformToBatch, &parentTransform, &nodeToParent);
            }

            //
            // calculate the Quad based on the Affine Matrix
            //

            Size size = _rect.size;

            float x1 = _offsetPosition.x;
            float y1 = _offsetPosition.y;

            float x2 = x1 + size.width;
            float y2 = y1 + size.height;
            float x = _transformToBatch.mat[12];
            float y = _transformToBatch.mat[13];

            float cr = _transformToBatch.mat[0];
            float sr = _transformToBatch.mat[1];
            float cr2 = _transformToBatch.mat[5];
            float sr2 = -_transformToBatch.mat[4];
            float ax = x1 * cr - y1 * sr2 + x;
            float ay = x1 * sr + y1 * cr2 + y;

            float bx = x2 * cr - y1 * sr2 + x;
            float by = x2 * sr + y1 * cr2 + y;

            float cx = x2 * cr - y2 * sr2 + x;
            float cy = x2 * sr + y2 * cr2 + y;

            float dx = x1 * cr - y2 * sr2 + x;
            float dy = x1 * sr + y2 * cr2 + y;

            _quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _positionZ );
            _quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _positionZ );
            _quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _positionZ );
            _quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _positionZ );
        }

        // MARMALADE CHANGE: ADDED CHECK FOR nullptr, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
        if (_textureAtlas)
		{
            _textureAtlas->updateQuad(&_quad, _atlasIndex);
        }

        _recursiveDirty = false;
        setDirty(false);
    }

    // MARMALADE CHANGED
    // recursively iterate over children
/*    if( _hasChildren )
    {
        // MARMALADE: CHANGED TO USE Node*
        // NOTE THAT WE HAVE ALSO DEFINED virtual Node::updateTransform()
        arrayMakeObjectsPerformSelector(_children, updateTransform, Sprite*);
    }*/
    Node::updateTransform();
}
Exemplo n.º 21
0
void FightLayer::initDisplay(){
    
    _nFight->setRotation3D(Vertex3F(-20,0,0));
}
Exemplo n.º 22
0
void ReversibleCard::verticalTilt(float duration, float deltaY, FiniteTimeAction *extActionBegin, FiniteTimeAction *extActionAfter)
{
	auto action = RotateBy::create(duration, Vertex3F(deltaY, 0, 0));
	auto tiltAnimIn = Sequence::create(extActionBegin, action, extActionAfter, NULL);
	this->runAction(tiltAnimIn);
}
Exemplo n.º 23
0
void ReversibleCard::verticalTilt(float duration, float deltaY, float delay, CallFuncN* callback)
{
	auto action = RotateBy::create(duration, Vertex3F(deltaY, 0, 0));
	auto tiltAnimIn = Sequence::create(DelayTime::create(delay), action, callback, NULL);
	this->runAction(tiltAnimIn);
}
void Plane::update(float dt){
    pRate+=0.01;
    _Model->setRotation3D(Vertex3F(0-pXA*sin(pXW*pRate),0,0-pZA*sin(pZW*pRate)));
}
// on "init" you need to initialize your instance
bool MainMenuScene::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
	pRate = 3.1415926/2;
    // Music By Matthew Pable (http://www.matthewpablo.com/)
    // Licensed under CC-BY 3.0 (http://creativecommons.org/licenses/by/3.0/)
    CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("Star_Chaser.mp3");
    
    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("menu_scene.plist","menu_scene.png");
    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Particle.plist","Particle.png");
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    
    //************ adds Plane ****************
    plane = Plane::create();
    this->addChild(plane, 10);
    this->scheduleUpdate();
    
    //************ adds emission flare ****************
    auto flare = ParticleSystemQuad::create("missileFlare.plist");
    flare->setScale(5);
    float originX = -9.0f;
    float originY = 159.0f;
    float originZ = 9.0f;
    flare->setTotalParticles(50);
    flare->setRotation3D(Vertex3F(-originX,-originY,-originZ));
    flare->setPosition(-39,0);
    flare->setPositionType(tPositionType::GROUPED);
    flare->setStartColor(Color4F(0,0.99,1,1));
    plane->addChild(flare, -1);
    
    auto emis = ParticleSystemQuad::create("menuEmission.plist");
    emis->setScale(3);
    emis->setRotation3D(Vertex3F(-originX,-originY,-originZ));
    emis->setPosition(-40,0);
    emis->setPositionType(tPositionType::GROUPED);
    emis->setRotation(180);
    plane->addChild(emis, -2);

    
    //************ adds vanishing ****************
    auto fileUtil = FileUtils::getInstance();
    auto plistData = fileUtil->getValueMapFromFile("vanishingPoint.plist");
    //auto sf = SpriteFrame::create("bullets.png", Rect(5,8,24,32));
    auto vanishing = ParticleSystemQuad::create(plistData);
    vanishing->setAnchorPoint(Point(0.5f,0.5f));
    vanishing->setPosition(visible_size_macro.width-90,visible_size_macro.height/2 +50);
    this->addChild(vanishing,1,1);
    
    //************* adds background ***********
    auto background = Sprite::createWithSpriteFrameName("mainmenu_BG.png");
    background->setAnchorPoint(Point(0,0));
    this->addChild(background,-1,-1);
    
    //************* adds start game ***********
    auto start_normal=Sprite::createWithSpriteFrameName("start_game.png");
    auto start_pressed=Sprite::createWithSpriteFrameName("start_game.png");
    startgame_item = MenuItemSprite::create(start_normal, start_pressed, CC_CALLBACK_1(MainMenuScene::startgame, this));
    startgame_item->setPosition(visibleSize.width/2,200);
    startgame_item->setScale(1.3);
    
    //************* license *******************
    auto license_normal=Sprite::createWithSpriteFrameName("license.png");
    auto license_pressed=Sprite::createWithSpriteFrameName("license.png");
    license_item = MenuItemSprite::create(license_normal, license_pressed, CC_CALLBACK_1(MainMenuScene::license, this));
    license_item->setPosition(visibleSize.width/2-200,100);
    license_item->setScale(0.7);

    //************* credits ******************
    auto credits_normal=Sprite::createWithSpriteFrameName("credits.png");
    auto credits_pressed=Sprite::createWithSpriteFrameName("credits.png");
    credits_item = MenuItemSprite::create(credits_normal, credits_pressed, CC_CALLBACK_1(MainMenuScene::credits, this));
    credits_item->setPosition(visibleSize.width/2+200,100);
    credits_item->setScale(0.7);

    //************* Menu ******************
    auto menu = Menu::create(startgame_item,license_item,credits_item, NULL);
    menu->setPosition(origin);
    this->addChild(menu,3);
    
    return true;
}
void MainMenuScene::update(float dt){
    pRate+=0.01;
    plane->setPosition3D(Vertex3F(visible_size_macro.width/2+50,480-20*sin(1.05*pRate),0));
}
void Fodder::setTurnRate(float turn)
{
    setMoveMode(moveMode::kTurn);
    setRotation3D(Vertex3F(fabsf(turn)*0.15, turn, 0));
    _turn = turn;
}
Exemplo n.º 28
0
Vertex3F Vertex3F::operator*(const float& f) const { return Vertex3F(p * f, n * f, c * f); }
Exemplo n.º 29
0
void ReversibleCard::verticalTilt(float duration, float deltaY)
{
	auto action = RotateBy::create(duration, Vertex3F(deltaY, 0, 0));
	auto tiltAnimIn = Sequence::create(action, NULL);
	this->runAction(tiltAnimIn);
}
Exemplo n.º 30
0
//------------------------------------------------------------------
//
// Atlas1
//
//------------------------------------------------------------------
Atlas1::Atlas1()
{
    _textureAtlas = TextureAtlas::create(s_AtlasTest, 3); _textureAtlas->retain();
    
    auto s = Director::getInstance()->getWinSize();

    //
    // Notice: u,v tex coordinates are inverted
    //
    V3F_C4B_T2F_Quad quads[] = 
    {
        {
            {Vertex3F(0,0,0),Color4B(0,0,255,255),Tex2F(0.0f,1.0f),},                // bottom left
            {Vertex3F(s.width,0,0),Color4B(0,0,255,0),Tex2F(1.0f,1.0f),},            // bottom right
            {Vertex3F(0,s.height,0),Color4B(0,0,255,0),Tex2F(0.0f,0.0f),},            // top left
            {Vertex3F(s.width,s.height,0),Color4B(0,0,255,255),Tex2F(1.0f,0.0f),},    // top right
        },        
        {
            {Vertex3F(40,40,0),Color4B(255,255,255,255),Tex2F(0.0f,0.2f),},            // bottom left
            {Vertex3F(120,80,0),Color4B(255,0,0,255),Tex2F(0.5f,0.2f),},            // bottom right
            {Vertex3F(40,160,0),Color4B(255,255,255,255),Tex2F(0.0f,0.0f),},        // top left
            {Vertex3F(160,160,0),Color4B(0,255,0,255),Tex2F(0.5f,0.0f),},            // top right
        },

        {
            {Vertex3F(s.width/2,40,0),Color4B(255,0,0,255),Tex2F(0.0f,1.0f),},        // bottom left
            {Vertex3F(s.width,40,0),Color4B(0,255,0,255),Tex2F(1.0f,1.0f),},        // bottom right
            {Vertex3F(s.width/2-50,200,0),Color4B(0,0,255,255),Tex2F(0.0f,0.0f),},        // top left
            {Vertex3F(s.width,100,0),Color4B(255,255,0,255),Tex2F(1.0f,0.0f),},        // top right
        },
        
    };
    
    
    for( int i=0;i<3;i++) 
    {
        _textureAtlas->updateQuad(&quads[i], i);
    }
}