#cocos2dX
Explore tagged Tumblr posts
impossible-rescue · 6 years ago
Text
Sprite Animation w/ Cocos2dx
For preparing the necessary technology with animation in cocos2dx, I made a really simple repo that includes a straightforward animation demo with cocos2dx.
Here is the development env:
Visual Studio 2017 Community
cocos2d-x-3.17.2
Tumblr media
For the sprite sheet and the assets, I used TexturePacker v5.0.9 Free version and bought assets from HumbleBundle. Based on those tools and resources, I made a simple sprite sheet[1] that includes an IDLE animation for a fighter.
Figure 1, the result of the sprite sheet
After that, I placed the sprite sheet to the resource folder inside the cocos2dx project folder.
Okay, all the assets and foundation are ready. Let’s code!
1.Load the plist (It comes with the sprite sheet when you publish a sprite sheet via TexturePacker)
// Load spritesheet info from plist SpriteFrameCache::getInstance()->addSpriteFramesWithFile("fighter.plist");
2.Create a extractor function to get all sprite frames for one animation
Vector idleFrames = this->GetAnimation( "idle_%d.png", 14 ); // ... // Get all sprite frames from the spritesheet based on a string format. // Need to pass the string format and how many frames that this animation has. // It returns a vector of SpriteFrame*. Vector HelloWorld::GetAnimation(const char* pchFormat, int iCount) { auto spriteCache = SpriteFrameCache::getInstance(); Vector animFrames; char str[100]; for (int i = 1; i <= iCount; i++) { // format string from parameters sprintf(str, pchFormat, i); printf(str); // add sprite to animFrames animFrames.pushBack(spriteCache->getSpriteFrameByName(str)); } return animFrames; }
3.Use the first item inside the vector and place it to the centre of the scene
// Set the default sprite frame to the first sprite frame in the vector Sprite* fighterIdleSprite = Sprite::createWithSpriteFrame( idleFrames.front() ); // Align sprite to center fighterIdleSprite->setPosition( origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2 ); // Add node to scene this->addChild( fighterIdleSprite );
4.Create animation object and apply update frequency
// Create animation by vector of sprite frames and the update fequency Animation* idleAnim = Animation::createWithSpriteFrames( idleFrames, 1.0f / 14 );
5.Apply it to the sprite by running runAction
// Apply animation to sprite by using runAction fighterIdleSprite->runAction( RepeatForever::create( Animate::create( idleAnim ) ) );
Result
Here is the repo link: Github Repo
The most important cpp file will be: HelloWorldScene.cpp Start from Line 105
0 notes
gpu-returns · 8 years ago
Text
複数のクラスのメソッドを指定のタイミングで同時に行う【Unity】
こんにちは!お久しぶりです。
「しまだ」です。
久々のブログ投稿になります。
なのでちょっとだけ近況報告をします!
最近は、いろんなゲームイベントに参加しながら東京ゲームショウ アマチュア部門向けのゲームを作っていました。
先日は5/20・5/21の二日間で京都のみやこめっせで行われた
「A 5th of BitSummit」に遊びに行ってきました。
BitSummitには毎年遊びに行っているんですが、今年も面白いゲームが多く展示してあり、二日間会場を動き回りましたw
実際に制作者の方とお話することもでき、刺激を受けることが出来たので、ゲームショウに向けてゲームを作りこんでいきます。
さて、そろそろ本題に入りましょう!
今回の内容はタイトルにもある通り「複数のクラスのメソッドを指定のタイミングで同時に呼ぶ」です!
僕は普段Cocos2d-xを使用してゲームを作っていたのですが、今回のゲームはUnityで制作しています。
Cocos2d-xで制作をしている際、「あるタイミングで異なるクラスのメソッドを一斉に行いたい」という時に「シングルトンのmanagerクラスに、メソッドを受け渡して保存しておく」ことで解決していました。
今回はこれをUnityでも行いたいと思い実装しました。
問題の処理なのですが、Cocos2d-xで行っていた処理はこんな感じでした。
#pragma once #ifndef __Test__TestManager__ #define __Test__TestManager__ #include "cocos2d.h" //シングルトンクラス using namespace cocos2d; using namespace std; class TestManager { public: static TestManager *_instance; static TestManager *getInstance();//インスタンスを取得 bool init(); void update(float delta); void test();//登録した処理を呼ぶ処理 void addFunc(function<void()> func);//処理を登録する処理 private: vector<void()> _testFunc;//メソッド登録用の配列 }; #endif /* defined(__Test__TestManager__) */
.hはこんな感じで
#include "TestManager.h" TestManager *TestManager::_instance; //シングルトンにする TestManager *TestManager::getInstance() { //インスタンスが作られてなかったら作る if (_instance == NULL) { _instance = new TestManager(); _instance->init(); } return _instance; } bool TestManager::init() { // updateが毎フレーム呼ばれるよう登録 Director::getInstance()->getScheduler()->unschedule("TestManagerUpdate", this); function _update = [=](float dt) {this->update(dt); }; Director::getInstance()->getScheduler()->schedule(_update, this, 0.0f, -1, 0, false, "TestManagerUpdate"); _testFunc.clear(); return true; } void TestManager::update(float delta) { } //登録した処理を呼ぶ処理 void TestManager::test() { for (auto func : _testFunc) { func(); } } //処理の登録用メソッド void TestManager::addFunc(function<void()> func) { _testFunc.push_back(func); }
.cppはこんな感じです。
メソッドを登録したいときは、登録したいメソッドを持っている側で
function<void()> func = [=]() { log("test"); }; TestManager::getInstance()->addFunc(func);
のように処理してあげることで登録しています。
function<void()> func = [=]() {  test(); }; TestManager::getInstance()->addFunc(func);
もちろん、ここで中身にメソッドを入れてあげることで、メソッドの登録もできます。
そして、本題となるこれをUnityで実装した方法なのですが
考え方自体はそのまま使用することができました。
変更するのは、配列とメソッドの引数だけです。
実際のソースはこちらになります。
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class TestManager : MonoBehaviour { public static TestManager _instance; //処理を登録するための配列 List<Action> _testFunc = new List(); void Awake() { //インスタンスが作られてなかったら作る if (_instance == null) { _instance = this; _instance.init(); } } //シングルトンにする public static TestManager getInstance() { return _instance; } bool init() { _testFunc.Clear(); return true; } void Start() { } // Update is called once per frame void Update() { } //登録した処理を呼ぶ void test() { for (int i = 0; i < _testFunc.Count; i++) { _testFunc[i](); } } //処理を登録する public void addFunc(Action func) { _testFunc.Add(func); } }
まず初めに、配列を動的に使用したいので、配列ではなくListを使用します。
Listを使用するためには、ソースコードの一番上に
using System.Collections.Generic;
を入れてあげる必要があります。
そして、Listの宣言方法ですが、
//List<型> 変数名 = new List<型>(); List<int> _test = new List<int>();
という形になります。
そして、登録するためのメソッドの型ですが、調べたところAction型を使用することで解決できました。
Action型を使用するためにも、ソースコードの一番上に
using System;
を入れてあげます。
そして、Action型を持ったListを作成します。
List<Action> _test = new List<Action>();
次に、Listにメソッドを登録するためのメソッドを作成します。
//処理を登録する public void addFunc(Action func) { _testFunc.Add(func); }
こちらにも、同じようにAction型を引数にしておきます。
Listに要素を追加する際には、Addを使用します。
これで、メソッドを登録する準備ができました。
あとは、登録したいメソッドを持��ている側のクラスで登録します。
Action func = delegate { test(); }; TestManager.getInstance().addFunc(func);
このように宣言することで、メソッドをAction型で受け渡せるようにします。
あとは、Manager側のクラスで
//登録した処理を呼ぶ void test() { for (int i = 0; i < _testFunc.Count; i++) { _testFunc[i](); } }
このメソッドを実行したいタイミングに合わせて呼んであげれば、指定のタイミングで異なるクラスの処理を一斉に呼び出すことができます。
僕は、Manager側にカウンタを作ることで、数フレーム毎に呼ばれる処理などに使用しています。
これで、今回のブログの内容は終了です!
ありがとうございました!
0 notes
redappletech · 6 years ago
Link
0 notes
magwolic · 7 years ago
Link
0 notes
stealthcoder · 8 years ago
Text
Enter Booty Quest
After some months soft launched in a small number of countries it seems that the world release date has arrived, and I can finally share the game I worked in during my time in Outplay: 
youtube
0 notes
kutumbh-blog · 8 years ago
Link
It has been always a challenge to integrate push notification to a project which is not written in native language. Cocos2dx projects which is based on c++ also has to face the same challenge.
0 notes
Text
COCOS2D X
Tumblr media
What is Cocos2d x ?
Cocos2d-x is an open source cross-platform game framework written in C++/Javascript/Lua. It can be used to build games, apps and other interactive programs. Cocos2d contains many branches with the best known being Cocos2d-objc, Cocos2d-x, Cocos2d-html5 and Cocos2d-XNA. There are some independent editors in the cocos2d community, such as those contributing in the areas of SpriteSheet editing, particle editing, font editing and Tilemap editing as well as world editors including SpriteBuilder and CocoStudio.
Features of Cocos2d: Sprites and scenes
All versions of Cocos2d work using the basic primitive known as a sprite. A sprite can be thought of as a simple 2D image, but can also be a container for other sprites. In Cocos2D, sprites are arranged together to form a scene, like a game level or a menu. Sprites can be manipulated in code based on events or actions or as part of animations. The sprites can be moved, rotated, scaled, have their image changed, etc.
GUI
Cocos2D provides primitives to representing common GUI elements in your game scene. This includes things like text boxes, labels, menus, buttons, and other common elements.
Animation
Cocos2D provides basic animation primitives that can work on sprites using a set of actions and timers. They can be chained and composed together to form more complex animations. Most Cocos2D implementations let you manipulate the size, scale, position, and other effects of the sprite. Some versions of Cocos2D let you also animate particle effects, image filtering effects via shaders (warp, ripple, etc.)
Cross Platform
Publish from a single code base to mobile, desktop, web, and console. Cocos2d-x allows developers to focus on building cutting-edge games while it takes care of the heavy lifting on the back-end.
Lightweight & Fast Running
Completely written in C++, the core engine has the smallest footprint, yet the fastest speed of any other game engine, and is optimized for running on all kinds of the devices including low-end Android systems.
Simple & Easy to Learn APIs
Cocos2d-x APIs are created and maintained by industry legend Ricardo Quesada who created the original, super popular Objective-C version. There is a variety of documents, tutorials, and demos to get you started, so dive in and experience Cocos2d-x first hand.
As we can see from above key points cocos2d is very handy software for game devlopment, and the sprites sheets which cocos2d makes that can be editable by using Plist software.
 Below is the link:  
http://store.bluegamerzstudio.com/downloads/spritesheet-plist-editor-for-texture-packer
Reference :
cocos2d.org wiki
0 notes
gamedev360-blog · 8 years ago
Video
(via https://www.youtube.com/watch?v=ACdIhRp3dcw) The secret of being IDEAL revealed! Watch carefully and repeat step by step! ;)
0 notes
symufaphotography · 8 years ago
Text
4 Amazing BuildBox Game Templates (Bundle 3): Android; Easy Reskin; AdMob & RevMob Ads & IAP (Games)
4 Amazing BuildBox Game Templates (Bundle 3): Android; Easy Reskin; AdMob & RevMob Ads & IAP (Games)
Purchase $89.00 These are the games that are included into that item: https://codecanyon.net/item/dangerous-fall-android-buildbox-included-easy-reskin-admob-revmob-remove-ads/18953622 https://codecanyon.net/item/levitation-android-buildbox-included-easy-reskin-admob-revmob-heyzap-remove-ads/18999869…
View On WordPress
0 notes
linuxgamenews · 2 years ago
Text
Knockout 2: Wrath of the Karen is hoping to solve problems with fighting on Linux
Tumblr media
Knockout 2: Wrath of the Karen boxing action game sees hope for Linux port with Mac and Windows PC. All due to further details from developer ExceptioNULL Games. Due to making its way onto Steam Early Access. Indie game studio ExceptioNULL Games just announced Knockout 2: Wrath of the Karen. Due to have you fight for your honor in a hilarious alternate reality. One where all problems are solved through boxing. Billed as a spiritual successor to Nintendo's Punch-Out!! games. Knockout 2 pits you against the worst of society. So the only way out is with your fists. Got cut in line at the grocery store? That's a boxing match. Offended a scam caller? That's a boxing match, too. In fact, all laws, court cases, and skimping out on sandwich toppings are resolved through combat. Doing so in a world where civil discourse has failed.
On top of that, there is hope for Knockout 2 on Linux:
We've switched from Cocos2dx to Unity for this sequel, making the port work easier. There's at least one other Linux gamer in our Discord asking the same thing. The biggest hurdle we face with committing to Linux is the lack of testing. If Knockout 2 fans can help us put a few hours behind a Linux build once we go Early Access, it would justify the effort.
Thanks to the ExceptioNULL email reply, there is hope for Linux. Since the studio has now switched to Unity 3D. Plus they will need Linux testers when the game hits Early Access for 3 - 6 months. At this time, it shouldn't be difficult to round up some Linux testers. Knockout 2 builds upon the exciting gameplay of its predecessor. ExceptioNULL Games once again flings their sharp comedic storytelling in all directions. As a result, no one is safe from the splashback. Knockout 2 leaves behind the electoral politics of the first game and takes on society at large. Then leading you on a road trip across America and around the world. Mete out pugilistic justice through fast-paced rhythm boxing gameplay. Including tight controls and charming graphics. Tricky opponents comewith a mix of traditional and modern animation. Since each has a puzzle to pick apart and solve before expertly playing them like a fiddle. Knockout 2: Wrath of the Karen boxing action game is releasing on Steam Early Access in 2024. So be sure to Wishlist the game. Due to making its way onto Linux with Mac and Windows PC. Stay turned, there is more to come.
0 notes
edudrems · 3 years ago
Text
youtube
C plus plus when we develop C plus plus programs we typically use the predefined functions in classes in the C plus standard libraries these are functions and classes that have already been written for us and tested and they're available for us to use we've already seen how useful the standard vector and standard string classes can be C plus plus has many other libraries that we can use in the same way depending on our application we may also use third-party functions in libraries these may be open source commercial or other types of libraries that have been developed by other programmers and are available to use in our applications so if we want to develop games in C plus plus we'd very likely use third-party libraries or Frameworks such as cocos2dx unreal spring cryengine or others why would we use third-party libraries well that's pretty easy because these libraries take a tremendous amount of effort to develop and chances are high that the functionality you need has already been implemented and tested and ready to use silt the wheel we're using existing functions in classes from existing libraries is great but even then you still need to write your own C plus functions in classes that are specific to the problem you're trying to solve we'll talk about classes and object-oriented programming soon in this section we'll focus on functions functions allow us to modularize our program this is a big deal since we can divide our program into logical self-contained units of code that we can reuse whenever we need to let's see a simple example on the left hand side of the screen you can see a program written in the way
0 notes
srimal85 · 3 years ago
Text
youtube
C plus plus when we develop C plus plus programs we typically use the predefined functions in classes in the C plus standard libraries these are functions and classes that have already been written for us and tested and they're available for us to use we've already seen how useful the standard vector and standard string classes can be C plus plus has many other libraries that we can use in the same way depending on our application we may also use third-party functions in libraries these may be open source commercial or other types of libraries that have been developed by other programmers and are available to use in our applications so if we want to develop games in C plus plus we'd very likely use third-party libraries or Frameworks such as cocos2dx unreal spring cryengine or others why would we use third-party libraries well that's pretty easy because these libraries take a tremendous amount of effort to develop and chances are high that the functionality you need has already been implemented and tested and ready to use silt the wheel we're using existing functions in classes from existing libraries is great but even then you still need to write your own C plus functions in classes that are specific to the problem you're trying to solve we'll talk about classes and object-oriented programming soon in this section we'll focus on functions functions allow us to modularize our program this is a big deal since we can divide our program into logical self-contained units of code that we can reuse whenever we need to let's see a simple example on the left hand side of the screen you can see a program written in the way
0 notes
yellowtiegames · 7 years ago
Video
tumblr
Something I was missing in the previous version on #cocos2dx was to create maps at runtime. Now, with #unity3d, using Voronoi diagrams I'm able to create endless maps variations. super cool!
1 note · View note
magwolic · 7 years ago
Link
0 notes
designthing-net · 5 years ago
Text
DOWNLOAD Magic Princess Makeup Salon
Tumblr media Tumblr media Tumblr media
You’ve been crowned a princess on a magic planet after a magical wish. Are you ready for a royal adventure? The people hold you to be their new darling, so you need to look the part.Magic Princess Makeup Salon is a fun makeover game for girls! In this beauty game you’ll meet a cute princess in a magical kingdom. Like any girl, she loves being pampered at the spa, putting on pretty makeup and dressing up in beautiful outfits. Come be her makeup artist and fashion stylist today! You’re the new star in the royal skies, so it’s time to get ready to wow your new people. You will want to look your best, so settle in for a nice day of relaxation at the spa. You’ll have the option for some spa treatments to get your skin looking luminous. Then, it’s time for a makeup makeover to get you ready for your starring role as Princess. A princess just isn’t a princess without a beautiful outfit, so play dress up until you find the perfect one to match your makeover. Voila! Images and audio tracks are not included with the main file (once they bought and download the item), that those are for demo or live preview purposes only. Game is developed using cocos2dx but here you get android studio deployment only so its not required knowledge of cocos platform you have to follow the steps from document for reskin game in android studio. You have to replace same size graphics & audio as well must require android studio knowledge seller is not responsible for lacking knowledge of android studio error or gradle issues we will only support if its coding issue. Requirements: You need to Android Studio. Monetisation: Admob ,Chartboost,Applovin Ads. Demo APK :https://play.google.com/store/apps/details?id=com.magicprincess
Tumblr media
Read the full article
0 notes
ios-goodies · 6 years ago
Text
Week 312
Happy Thursday! This week we got iOS 13.3 and Xcode 11.3 GM. Best feature of iOS 13.3 for me? I can now get rid of the memoji stickers from the emoji keyboard 😅. Let’s go to the links!
Marius Constantinescu
Articles
The Advanced Guide to UserDefaults in Swift, by @V8tr
Building bottom sheet in SwiftUI, by @mecid
Advanced asynchronous operations by making use of generics, by @twannl
Lessons learned from handling JWT on mobile, by @justeat_tech
Quick tip: clearing your app’s launch screen cache on iOS, by @_inside
Handling deeplinks in your app, by @donnywals
All you never wanted to know about state in SwiftUI, by @plivesey453
Building Adaptive Layout with Size Classes — Programmatically, by @batikansosun
Understanding Structural Design Patterns, by @AshliRankin18
Tools/Controls
Cocos2d-x 4.0 - mature cross-platform game development framework which now supports metal, by @cocos2dx
NativeConnect - Desktop client for App Store Connect, by @NativeConnect
Pecker - CodePecker is a tool to detect unused code, by @Roy78463507
Alley - Essential URLSessionDataTask micro-wrapper for communication with HTTP(S) web services, with built-in automatic request retries, by @radiantav
UI/UX
Can You Learn Design?, by @jordanmorgan10
Credits
V8tr, ramshandilya, albertodebortoli, pmusolino, mecid, plivesey, LisaDziuba
0 notes