SpriteKit to Axmol (original) (raw)

Converting SpriteKit games to Axmol Engine

For the most part, SpriteKit and Axmol Engine are almost identical, so a game conversion from iOS to Android is not a hard task. Please keep in mind there are some name changes (i.e. alpha -> opacity, zPosition -> zOrder, etc.), and also take in account the indications in the sections below.

Important: Add your code to the Source folder and your assets to the Content folder. All the code in this wiki page is shown with USING_NS_AX active. auto will choose the correct variable or pointer type for you.

Sprites, positions and other nodes

parent->getContentSize().width / 2  
parent->getContentSize().height / 2  

Actions

auto rotateLeft = RotateTo::create(6.0f, 25.0f);  // Action to ease  
auto easeRotateLeft = EaseInOut::create(rotateLeft, 3.0f);  // Easing  
auto moveSprite = MoveTo::create(2.0f, Vec2(100, 100));  // Original action  
auto speedMoveSprite = Speed::create(moveSprite, 1.0f);  // Setting the base value  
speedMoveSprite->setSpeed(0.2f); // Setting the speed to a 20% of the original  
auto runBlockEquivalent = CallFunc::create([=](){  
  // Do something  
});  

Assets

Label::createWithTTF("", "fontName.ttf", 24);  
AudioEngine::preload("sound.ogg", [](bool success){  
   AXLOG("Audio preloaded");  
});  

Touch

Node *parentNode = event->getCurrentTarget();  
Point touchPosition = parentNode->convertTouchToNodeSpace(touches.at(0));  
for(const auto& node : parentNode->getChildren()) {  
   if (node->getBoundingBox().containsPoint(touchPosition)) {  
       if (node->getName() == "My node name")  
       {  
        // Do something  
       }  
    }  
 }  

Data & others

Extensions

There are several elements of Apple's frameworks that doesn't exists in Axmol. You can program your own solutions, but some of them are available as extensions in our Made in Axmol page. For example,

Memory management


This list is not comprehensive by any means, but it may be a good start point. If you have more questions, please check our FAQ, our Tutorials page and GitHub discussions.