You are here

Qt ,Maemo and some other stuff

Qt ,Maemo and some other stuff
Checked: 1 hour 59 min ago
Updated: 1 hour 59 min ago
Update every: 2 hours

Sharing information related to Qt, Maemo development and some other information
Subscribe to Qt ,Maemo and some other stuff

Custom UISwitch in iOS

Qt ,Maemo and some other stuff - Sun, 11/10/2015 - 5:25am
I wanted to create Custom UISwitch in my iOS game. Initially I just waned to change size, font and color and for that I used UICustomSwitch from Hardy Macia found at here. It's quite easy to use and customisable, but then I wanted to switch to use custom image instead of standard one. For that I need to modify code a bit, below is the code which use custom image to create UISwitch. BTW this is how it looks

The Math Game for iOS

Qt ,Maemo and some other stuff - Sun, 16/08/2015 - 8:23am
If you have read my previous posts, you might already know I was trying to learn Swift language. While doing so I tried to create a simple game.

Finally I was able to complete the app and was able to publish it as well. You can download app from here.
Below is demo of the game.

You can also get more information about app here.

Displaying Game Centre Leaders board from Swift

Qt ,Maemo and some other stuff - Sat, 18/07/2015 - 3:09am
In last post, I showed how we can authenticate local player and how we can post score to default leader board.

In this post, I will show how we can display leader board using swift gamekit API. Below code shows how we can display GKGameCenterViewController. Game center viewcontroller needs delegate, which is called when view is dismissed. Also we need parent viewcontroller which will be used to display GKGameCenterViewController.

func showLeaderboard(viewController: UIViewController,
gameCenterDelegate: GKGameCenterControllerDelegate) {

Creating array of IBOutlets of NSLayoutConstraint's from Swift in iOS

Qt ,Maemo and some other stuff - Sat, 11/07/2015 - 4:14am
While working on my iOS app, I wanted to modify UI Constraint set from Interface Builder from Swift code.

Below video shows how we can create Array of IBOutlets using Interface Builder. Here I am creating array of NSLayoutConstraint, which I want to modify from Swift Code.



Now lets see how we can manipulate constraints from swift. First we need to define array of IBOutlet. Below code shows the same.

@IBOutlet var constraints: Array?

Posting score to Game Kit Leader board using swift

Qt ,Maemo and some other stuff - Mon, 29/06/2015 - 5:37am
As you might already know, I recently started exploring Swift language and now I am trying out GameKit framework. While I have some experience in working with GameKit using Objective C. I wanted to do the same thing using swift. As such there are no API changes while using GameKit with Swift or Objective C. However there are some syntax change.

In this post, I will show how to Authenticate local player using GameKit framework and post score to LeaderBoard defined in iTune Connect Application setting.

Using NSNotificationCenter in Swift

Qt ,Maemo and some other stuff - Sun, 28/06/2015 - 1:42am
NSNotificationCenter is a convenient method to implement Observer pattern in iOS, something similar to what we say Signal/Slot in Qt framework.

To register one self as observer to some event, you can use addObserver method form NSNotificationCenter. In below code you are adding self as observer, selector is method which will be called when event is triggered, name is name of event or notification in which we are interested in, and object is object from which we want to receive event from, nil means we are ready to receive event from any object.

Playing sound using Swift

Qt ,Maemo and some other stuff - Fri, 26/06/2015 - 2:11am
Posting small code snippet to that shows how to play sound using Swift in iOS.

First we need to import AVFoundation.

import AVFoundation
Then we need to create instance of AVAudioPlayer. I created a small utility function like below for the same.


private static func createAudioPlayer
( sound: String, type: String ) -> AVAudioPlayer {

var error:NSError?;
let soundUrl = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(sound, ofType: type)!);
println(soundUrl)

Performing Segue and Passing data in iOS

Qt ,Maemo and some other stuff - Sun, 07/06/2015 - 9:23am
I was trying to learn how to perform view switching using Segue for UI created by StoryBoard. Using Segue is quite easy and convenient. You can create Segue from Interface Builder, which associate action to view. Like if you click some button then you can associate this click action with view switch and you can select which view to switch to. This all is quite simple and can be done using simple drag and drop.

Drawing round border around UIView in iOS

Qt ,Maemo and some other stuff - Sun, 07/06/2015 - 2:20am
I wanted to create a subview UIView with round border in iOS. I found following code works very well to draw round border around UIView. While this code is written swift you can easily write similar code in Objective C as well.

Following is the code. As you can see, I selected subview UIView and made is IBOutlet using Interface Builder. Once that is done you can see round border around view.


@IBOutlet weak var contentView: UIView?

override func viewDidLoad() {
super.viewDidLoad();

Hiding status bar in iOS8 using Swift

Qt ,Maemo and some other stuff - Sat, 06/06/2015 - 3:18am
I recently started learning swift, while learning I started to create simple game. I wanted to make my game full screen, but I was unable to hide top status bar from Interface builder. No matter what I change that status bar was always visible.

Buf I found following code snippet, if you add this code in your View Controller file, you can easily hide status bar.

override func prefersStatusBarHidden() -> Bool {
return true;
}
Following how my ViewController file looks after adding this code.

Color Animation using Animator with Unity3D

Qt ,Maemo and some other stuff - Mon, 04/05/2015 - 5:47am
I created a small demo application to demonstrate how Animation can be done using Animator and State Machine with Unity5. This demo creates a Blinking Animation on Mouse click.

Following is final output of this demo.


Below post shows, how above animation can be created.

-> To begin, First create a simple cube and apply a material on the cube. Setup should look like below.

Handling Drag and Drop with Unity 3D

Qt ,Maemo and some other stuff - Sun, 12/04/2015 - 11:25am
Drag and Drop is quite useful and we need to implement this quite often in our project. While working on one of my Unity Project, I required to implement the same.

There are some options but I found code described in this post quite simple to use with my project. In this post I will describe how I achieved the same.

Sprite with Text in Unity3D

Qt ,Maemo and some other stuff - Sun, 05/04/2015 - 6:10am
I am working on one game where I wanted to show text over sprite. With new Unity UI System, it's quite easy to create button as sprite and text over it.

But if you want to create a traditional sprite and add text to it, this post describes the same.

Basic idea is to add 3D text component to sprite, but if you have tried it then you might know after adding 3D text component we need to move it to same sorting order as sprite. Also we need to layout text properly to set alignment.

Notification on property change in iOS SDK

Qt ,Maemo and some other stuff - Sun, 25/01/2015 - 3:35am
I have used QML quite a lot in my projects and there is one quite nice feature in QML that makes implementation quite easy. The feature is Property change notification.

Apple iOS SDK also similar mechanism named Key-Value Observing mechanism. Here is Apple's documentation for the same.

Showing Remote Image using ImageView in BB10 Cascades

Qt ,Maemo and some other stuff - Sun, 28/12/2014 - 2:16am
While working on my BB10 App update, I required to show Remote Image using ImageView BB10 cascades API. ImageView or Image component by default does not support loading image from URL on internet. I implemented a custom component which serve the purpose and also easily integrated with ImageView.

Following is implementation for the same, I hope it will be useful to someone.

Resolving "_clock$UNIX2003", referenced from" error

Qt ,Maemo and some other stuff - Sun, 21/12/2014 - 4:17am
I was trying to build Unity 3D project for simulator SDK. I wanted to get different screen size screen shot. But when I tried to build it I got following build error.
_clock$UNIX2003", referenced from
I found one work around to resolve this issue. We need to add following patch to main.mm file.
#include <time.h>

// "_clock$UNIX2003", referenced from:
//Temporary hack for building Simulator Project for Unity
extern "C"
{
clock_t
clock$UNIX2003(void)
{
return clock();
}

Your Shot Ubuntu Touch Scope

Qt ,Maemo and some other stuff - Sun, 23/11/2014 - 11:38am
You might have heard about Ubuntu Touch, and one of unique feature of Ubuntu Touch is Scope. Recently they also announced Ubuntu Touch Scope competition. This got me interested, I wanted to learn about Scope development, so I thought to take part as well in the competition.

You can get more information about competition here.

Creating dynamic QML object asynchronously

Qt ,Maemo and some other stuff - Thu, 30/10/2014 - 2:44pm
We can create QML object dynamically by using createComponent and createObject API.

Like follow,

var component = Qt.createComponent("Button.qml");
if (component.status == Component.Ready)
component.createObject(parent, {"x": 100, "y": 100});
You can find more information regarding same here.

Creating array of IBOutlet

Qt ,Maemo and some other stuff - Sun, 14/09/2014 - 3:13am
Sometimes you want to enable/disable bunch of buttons together or perform other such activities on bunch of UI elements created using Interface Builder.

I recently needed to perform similar operation on bunch of button for iOS game I am working on. For this kind of operation, its easier to create array of IBOutlet which can be created using IBOutletCollection. Following is my code, which create IBOutletCollection of UIButtons and then enable/disbale them together.
@interface MyViewController : UIViewController {

Matching custom NSObject with isEqual and hash

Qt ,Maemo and some other stuff - Wed, 10/09/2014 - 8:03am
While working on one multiplayer game for iOS using GameKit, I faced issue while comparing object.

For single player version I was not facing this issue but while running multiplayer version I was facing this issue. After debugging a little I realised condition for comparing object's value is failing and it turned out that I was comparing object's address rather then its value. As for Multiplayer game I was creating object using data from server/host, I needed to compare object's value and not its address.

Creating simple fade animation with Unity3D

Qt ,Maemo and some other stuff - Sat, 05/07/2014 - 6:14am
I recently used fade animation or opacity animation with one of my Unity game, it was used to fade then earned points during game play. Initially I struggled a bit to achieve opacity animation due to confusion between using Animation or Animator. Look like from Unity version 4.3 we need to use Animator to animate the properties. I was trying to use Animation instead of Animator, was not able to perform opacity animation properly.
In this post I will show, how I accomplished the Fading animation. below is video of final effect and whole process to achieve animation.

Creating global variable in Unity3D

Qt ,Maemo and some other stuff - Sat, 05/07/2014 - 3:32am
Sometime you want to create Global object that you can access from whole project. Recently while working on my unity game, I also needed the same.

While method is quite simple to achieve the same, but its quite confusing if you are just started with Unity3D just like me. Finally I now understand the process, and in this post I am describing how we can create global variable with Unity3D.

Resolving Folder reading issue from SD Card in BB10

Qt ,Maemo and some other stuff - Sat, 28/06/2014 - 11:34am
There was a tricky bug in Audiobook Reader BB10 version for quite a some time which I was trying to resolve. Issue was that, for some folder in SD card, I was not able to browse it using QDir Qt API or Posix API. Though API was showing the folder, but when I try to find out folder's content, it reports folder as empty.

This was causing serious usability issue with Audiobook Reader application, as user were not able to add book from SD card. I debugged it long and tried to use various approach to resolve the issue but could not find any satisfactory solution.

Audiobook Reader for BB10 now got Built for Blackberry status

Qt ,Maemo and some other stuff - Thu, 26/06/2014 - 2:17pm
Recently I upgraded my Audiobook Reader application pro version for BB10.

This version contains many UI related changes and now it is more aligned to Blackberry design guideline and now it is also awarded Built for Blackberry status.

Apart form UI related changes, this version contains two major changes.

Now it Book auto pauses in case it detect phone call activity.

Using WorkerScript from QML

Qt ,Maemo and some other stuff - Fri, 13/06/2014 - 1:35am
As you might know, I am contributing to Ubuntu Touch Calendar core application. Those application are pure QML application with no C++ backend or we aim to avoid it as much as possible. This is done to make sure application are portable across device.

For simple use-case you can just use javascript code as backend logic and it should work fine without any problem. but if you need to some intensive calculation in application then its better to move those calculation to WorkerScript.

Pages

Subscribe to Qt ,Maemo and some other stuff