Author: jjordanarenas (page 1 of 2)

Adding AdMob banners to SpriteKit games

Usually we, indie game developers, need to monetize our creations by showing advertisements but don’t worry, in this tutorial you will learn how to add an AdMob banner to any scene of your games.

This tutorial will consist on three sections:

  • Creating a new AdMob banner
  • Installing Google’s CocoaPod
  • Adding the banner to your game

Note that we are not covering the way to create a new SpriteKit game because you’re supposed to know it before thinking on adding the ads. If not, don’t try to put the cart before the horse. :)

Creating a new AdMob banner

First of all you need to log into AdMob‎ (create a new account if you don’t have one).

Then access the Monetize link on the top menu and then click on the Monetize new app button placed on the top left of the screen.

We are creating the banner for a game that is not on the App Store yet so choose Add your app manually on the following screen and.

Enter My banner game (or your desired game) into App name and choose iOS on Platform and click Add app.

Select Banner as format for the advertisement, edit the style and enter My first banner (or another desired text) as the name of the ad unit before clicking on Save.

After these steps you will find a unit ID (take note of it and keep it close for the future) and a link where you will see how to add the new banner to an iOS app but it doesn’t cover how to add it to your game, which is a little different. Don’t worry you will learn it in the last section of this tutorial.

Installing Google’s CocoaPod

For this purpose you better follow Google’s official guide, which provides the steps to get the resources needed to render the banner on your game.

Adding the banner to your game

Time to code! This is the key step of the process as adding a banner to a game is slightly different than to an app due to the classes used in each of both types of products.

  • Open your game on Xcode (remember to choose the .xcworkspace file) and add the following line to GameScene, just after “import SpriteKit”:

    import GoogleMobileAds

    This way you will be able to use the classes provided by GoogleMobileAds framework.

    Now we can declare a couple of variables that will be useful for our purpose so add the following lines just before the didMoveToView method:

    var viewController: GameViewController!
    var bannerView: GADBannerView!

    With these lines you are declaring a view controller and a GADBannerView, which will render an AdMob banner.

  • Then is time to initialize the banner so, for this purpose, first add the below code at the end of didMoveToView:

    if bannerView == nil {
    initializeBanner()
    }

    And implement this new method with the following lines:

    func initializeBanner() {
    // Create a banner ad and add it to the view hierarchy.
    bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
    bannerView.adUnitID = "ca-app-pub-5767684210972160/3268052334"
    bannerView.rootViewController = viewController
    view!.addSubview(bannerView)
    }

    You are creating a new GADBannerView specifying the smart banner portrait size, which you can modify if you want to show a different kind of banner.

    Then you specify the unit ID that you took note previously and set the root view controller as the one we have declared before.

    Finally you add the banner to the game’s view.

  • Now that the banner is ready you can request an ad so let’s call a new method by adding the following line at the end of didMoveToView:

    loadRequest()

    And implement it with the following lines:

    func loadRequest() {
    let request = GADRequest()
    request.testDevices = [kGADSimulatorID, "22ed9df524b90565f5e15t23ad232415"]
    bannerView.loadRequest(request)
    }

    You first create a new ad request and then specify the devices you will use to test it (this way you will avoid the possibility of getting penalized by AdMob if you request so much ads during the test process). In above’s example I’m specifying the Xcode simulator and my iPhone’s id, which I got previously by running the game on it.

    Finally you load the new request on the banner view.

  • There is only a left step, which is to initialize the viewController variable we are using. For this purpose go to GameViewController and add the following line before the initialization of the skView constant:

    // Linking view controller and scene to show ads
    scene.viewController = self

    This way you link your game’s view controller to the root of the banner view.

  • If you run the project now you will see something similar to this image:

    Simulator Screen Shot 29 Mar 2016 17.08.00

    And that’s all, you now can load any kind of ads to your games!

    You can find the source code of this tutorial here.

    @jjordanarenas

One Game a Month – February

During the month of February we have joined a couple of developers and a designer to participate on the One Game A Month challenge.

This month’s word is home and as soon as we knew it we started working on the different ideas provided by each team member. After a couple of days of brain storming we chose the subject of our game and we started giving shape to our idea.

The game is in progress and there is not much to show you but we will share one of the designs you will find in this iOS game we are developing.

character16

@jjordanarenas

Book: 2D iOS & tvOS Games by Tutorials

During the past weeks I’ve had the opportunity of reading one of the latest jobs by my colleagues from www.raywenderlich.com, the book: 2D iOS & tvOS Games by Tutorials.

I can’t help to say or write that this title is one of the most brilliants I’ve read from them and it’s not just void words, they are held by tangent reasons.

The book is written for a wide range of spectators: from the most noobs to the experienced ones. If you have never heard about SpriteKit or even wrote a line in Swift (yes, the code of this book is completely written on the last version of this amazing language) you will be able to follow the instructions provided by the book.

On the contrary, if you count with a background on game development you can over-read the first part of the book and start reading the chapters related to advanced game development and tvOS game support. Yes, this title provides detailed explanations on how to develop games for the Apple Tv and how to get rid of the common problems we face when working with the brand new tvOS.

2d_tvos_cover

2D iOS & tvOS Games by Tutorials is organised in six main sections which will teach you the following contents progressively:

  • Getting Started: Shows how to create a basic 2D game creating sprites and applying actions and movements to them. In addition it teaches how to build scenes, labels and how to manage the camera. Finally you will also learn how to take advantage of the code developed on this section to port the game for Apple Tv.
  • Physics and Nodes: Introduces the Scene Editor to generate scenes. This section also teaches how to create a game with physics and how to play videos, crop nodes and create shapes. In addition you will also give a step forward on your tvOS knowledge.
  • Juice: Teaches a technique introduced by Apple on the last version of Sprite Kit: state machines, thanks to which we can handle the status of our game easily. It also teaches how to generate particle systems such as explosions and other techniques to create interesting games audio-visually.
  • GameplayKit: Shows how to take advantage of some of the features included this brand new tool which provides support to create pathfinding, agents, goals and provide behaviour to the agents.
  • Advanced Topics: Teaches complementary techniques such as creating tile maps, using the randomisation provided by GameplayKit, how to generate procedural levels or supporting external game controllers.
  • Bonus Chapters: These last pages show some complementary techniques to create a whole product with Game Center achievements and Leaderboards, using the new ReplayKit, how to include advertisement in our games and how to find or create 2d art for our games.

As you can see on the contents above, this book is a must if you want to be on the front of game development, specifically if you want to be one of the first developers creating games for this renovated device: the Apple Tv.

@jjordanarenas

Simon Says for Apple Watch

Now we also develop games and apps for Apple Watch!

Our first work is a replica of Simon Says. This game bring us back to the 80s with this classic memory training board game.

simon-hero

Try to reproduce what the AI says as far as you can and try to demonstrate that you’re smarter than it.

And now you can also download it on the App Store!

Download_on_the_App_Store_Badge_US-UK_135x40

Purchase this game template and make your own versions to upload on the App Store!

@jjordanarenas

Book: Cocos2d games development

Few days ago my first book about Cocos2d games development was released by Packt Publishing: Cocos2d Game Development Blueprints.

It has been a hard but very interesting process which I’ve enjoyed a lot and which gave me the chance to contribute with the game developers community.

What are you going to find in this book? Cocos2d Game Development Blueprints shows how to develop 8 games based on different video games genres such as horizontal scrolling, platforms, tower defense, beat ‘em up, shoot ‘em up, multiplayer cards, quiz, and sports.

The contents on the book are ordered in an increasing difficulty. This way you will learn step by a step from the most easy thing, such as adding a background to your games, to advanced concepts such as kinematic bodies.

Cocos2d_game_development_blueprints_cover

In the first chapter you will learn how to create a horizontal scrolling game in which you will add some sprites, backgrounds, sounds and labels. In this game you will try to make the main character (our great friend Joselu the Yeti) avoid some snowballs that are trying to hurt him. For this purpose you will also learn to detect and manage collisions.

The second chapter puts you in the skin of Dr. Nicholas Fringe, a crazy scientific who wants to protect the Earth from the attack of dangerous UFOs with his only two inventions: a laser beam gun and a backpack-reactor. In this chapter you will learn how to implement the parallax effect, to draw geometric primitives, how to use the accelerometer and how to load and set up a particle system.

With the intention of creating a cards game similar to Magic or Hearthstone: Heroes of Warcraft, in chapter three you will learn how to implement a turn-based game integrating Game Center, to implement actions and transform sprites.

Chapter number four is based on one crazy plot: the main character is a zombie in the middle of a human apocalypse and you have to beat all the enemies up to survive. Along this chapter you learn to build a virtual game pad, to animate sprites using multiple image files and how to optimise it by using sprite sheets.

If you continue reading, in the chapter five you will create a quiz game with its tutorial, and how to create transitions between scenes which you will load thanks to external files data.

The following chapter, chapter number six, is a very interesting one. Along theses pages you will learn how to create a game’s physics with bodies, shapes, collisions, and thanks to that you will develop a snooker game.

In chapter seven you will need to help Joselu again. In this case he is in a platform world which you have built thanks to a variety of terrain images, and with custom collision logic. You will also learn how to add a menu to your game.

The final chapter is a classic defend-the-tower game. This is the perfect genre to introduce some AI stuff such as a pathfinding algorithm for the enemies or some smart behaviour for the defenses. In this chapter you will also learn how to predefine positions for the defenses and how to load waves of enemies and share information between nodes.

Ok, I said a lot of things, I will stop writing. Have you realised how cool the cover is? There are more of these amazing designs inside ;).

@jjordanarenas

Romanian MobOS 2015

Past 19th and 20th of February took place the second edition of the Romanian Mobile Operating Systems Conference, also known as MobOS, in the beautiful city of Cluj Napoca (Romania).

mobosLogo

It was two days full of interesting talks and workshops subdivided in iOS and Android tracks in which I proudly participate as a speaker together with other nine amazing professionals.

The first day had five presentations per track and I made an overview of Apple’s game development’s frameworks (Sprite Kit and Scene Kit) comparing them with the omnipotent Unity3d.

The following day I addressed one of the two workshops where I showed how to migrate a game from Objective-C to Swift. This way the attendees learnt two things at the same time: how to develop a game with Sprite Kit and how to translate a code written in Objective-C to Swift.

speaker

Apart of that knowledge sharing, the organisers of the conference had planned some surprises in the form of amazing giveaways such as an iPod, some wearables and a copy of my book: Cocos2d Game Development Blueprints.

The conference was an absolute success with more than 200 participants, exceeding the initial expectations, and I’m sure MobOS is going to be (if not already) one of the most important conferences on the eastern Europe.

I cannot do other than thank the people from the organisation for making me feel at home, for making real such an amazing event and for giving me the opportunity of trying the papanasi, a typical Romanian dessert :).

papanasi

@jjordanarenas

Geo Events 2.0

We are happy to announce that the latest version of Geo Events has been published on the App Store!

iTunesArtwork@2x

We’ve been working hard the last months to offer you the events in a new language: english, and, taking advantage of the new look and feel of iOS 7, we’ve made Geo Events a more intuitive and friendly product.

In addition, we’ve changed the app icon by a more fancy one, so you’ve no excuses to put it on the first page, beside the coolest applications!

You can download it, free or paid (0.99 USD), both for iPhone and iPad:

Geo Events Lite

Download_on_the_App_Store_Badge_US-US_135x40

Geo Events

Download_on_the_App_Store_Badge_US-US_135x40

@jjordanarenas

A good course to start iOS development: Beginning iOS (iPhone / iPad) by Big Nerd Ranch

This post is dedicated to those who, like me a few months ago, are looking for a course to learn how to develop iOS applications and do not know which to choose.

During the holidays I enjoyed last summer I could stop and think about the way I was following in this iOS development’s world. Thanks to that, I saw myself immersed in a maelstrom in which the only thing I was doing during the last months was just develop, develop and develop and I realized about the gaps in my knowledge. Yes, over these years I have learned many things but at that moment I realized that the foundations that supported my skills were weak and that, if I wanted to grow as an iOS developer, I would need a solid basis to be able to sustain anything that I would build in the future.

That opened my eyes and convinced me that I needed to form myself better, it was not enough reading and developing like crazy, I needed to study well. I then started looking online or classroom courses that fit what I was looking for: something that would provide me the expertise that I lacked and prestigious enough to make my resume coolest. I saw some interesting online courses, both pay and free, but they didn’t seem to be supported by prestigious schools or companies. Then I found the Big Nerd Ranch, which I didn’t know that was imparting courses besides publishing development books, that looked very interesting but I didn’t decide to take this course because of its cost, my ignorance about if they had prestige and the fact that I would have to travel to USA or the Netherlands to attend to it.

Continue reading

iOS 7 by tutorials + Sprite Kit

i7T_iGT_bundle_PDF_640_authorTBA@2x

As many of you know, iOS 7 is about to be released and with it, a lot of news for us developers. With each new version of iOS we find the inconvenience of having to catch up and learn the intricacies and, what better way than learning by tutorials?

Fortunatelly, another year Ray Wenderlich’s team started working as soon as the details of the new version have been known and they have worked hard to compile the key contents in a fantastic book: iOS 7 by tutorials. I, as owner of the two previous editions the content, totally recommend it.

iOS7_PDFonly_280_authorTBA

Also this year, Apple has surprised us with Sprite Kit, a powerful framework for 2D games, that’s why Ray and his boys decided to dedicate a whole book. With it we’ll learn how to make games with the fantastic Sprite Kit, looks great!

Spritekit_PDFonly_280_authorTBA

@jjordanarenas

Learn to develop games with Cocos2D-X

book_coverCocos2d-X by Example Beginner’s Guide written by Roger Engelbert was published last month and, as a good geek, did not hesitate to order it in both digital and paperback versions and read it as soon as I could.

I have to say I’m not disappointed. On the contrary, I think the subjects are very interesting and the way the book takes you through the development of increasingly more comprehensive and complex games, you finish the book without realizing it and want to read another chapter, as if it were The Da Vinci Code!

Perhaps the only downside I found is that the book uses Cocos2d-2.0-x-2.0.4 when the actual version available is Cocos2d-2.1rc0-x-2.1.3 but, since this version has only been out for seven months and the author had to write the book in this time, we can’t criticize. In addition, on his website there is already a post with changes to adapt the code to the latest version, so another positive point for Roger.

I recommend this book to those who are interested in learning to develop using Cocos2D-X. For more info or content details keep reading to see a summary of each chapter.

Continue reading

Older posts
%d bloggers like this: