Monthly Archives: March 2016

IMD 1_To Do List (1)

Our second project! To Do List!

Let’s create a new project.

스크린샷 2016-03-29 오전 11.48.11.png

스크린샷 2016-03-29 오전 11.49.57.png

Make sure to check ‘Use Core Data’.

스크린샷 2016-03-29 오전 11.52.13

We will gonna make our own database. We got an .xcdatamodeld. This is our core data.

스크린샷 2016-03-29 오전 11.54.29

Delete ViewController.swift and move to trash.

스크린샷 2016-03-29 오전 11.56.51.pngAnd delete Main.storyboard, too. We will make our new storyboard.

스크린샷 2016-03-29 오전 11.58.59.png

In the bottom, click ‘add entity’.스크린샷 2016-03-29 오전 11.59.35.png

스크린샷 2016-03-29 오후 12.00.30.png

스크린샷 2016-03-29 오후 12.03.48.png

In the Attribute, we added 3 String. Upper and Lower case is very important. Double check your capital letter is right.

스크린샷 2016-03-29 오후 12.06.05.png

And we will going to make a 3 new file.

스크린샷 2016-03-29 오후 12.06.21.png

Choose ‘Swift File’.

스크린샷 2016-03-29 오후 12.07.41.png

스크린샷 2016-03-29 오후 12.08.48.png

스크린샷 2016-03-29 오후 12.10.15.png

1. Model.swift

2. listTableViewController.swift

3. itemViewController.swift

스크린샷 2016-03-29 오후 12.42.37.png

And go to Main.storyboard, let’s drag Navigation Controller to your screen.

You can change your size. I’ve made it iPhone 4.7-inch(iPhone 6).

We made some code to Model.swift.

스크린샷 2016-03-29 오후 5.20.29.png

And Go to listTableViewController.swift.

We wrote some code here, also.

스크린샷 2016-03-29 오후 5.20.37.png

스크린샷 2016-03-29 오후 12.47.08.png

Click ‘Prototype Cells’ and type ‘Cell’ to Identifier.

스크린샷 2016-03-29 오후 12.47.38.png

And the style will be ‘Subtitle’.

스크린샷 2016-03-29 오후 12.47.56.png

Next class, we will fill out our code.

My Dropbox Link :

https://www.dropbox.com/s/d1kwehx8gvk5dzb/todoClass_1212200.zip?dl=0

 

 

 

IMD 1_Xcode RGB Slider 3

The third class of making RGB Slider.

We’ve learned how to update color without clicking.

When we simulate the RGB Slider, the color patch screen is white. But it should be gray because R=127, G=127, B=127. It’s little weird. So we will going to add some code to solve that problem.

  // call the updateColor fuction to set the initial color.

        updateColor(redSlider)

This code will fix that problem.

스크린샷 2016-03-29 오전 10.29.29      스크린샷 2016-03-29 오전 10.29.07

Now our initial color is fixed to grey!

Next step is making a reset button. Search a button at the filter, and drag it to your screen.

스크린샷 2016-03-29 오전 10.53.53.png스크린샷 2016-03-29 오전 10.37.47.png

And connect the line with reset. Write the code like this.

@IBAction func resetPressed(sender: AnyObject) {

        redSlider.value = 0.5

        greenSlider.value = 0.5

        blueSlider.value = 0.5

        updateColor(redSlider)

Now we got our reset button. You can make your own personal preset by changing the number 0.5.

스크린샷 2016-03-29 오후 3.20.24.png      스크린샷 2016-03-29 오후 3.32.37.png

Now we’re going to make an app icon.

The size of the icon is usually 1024*1024 pixels.

스크린샷 2016-03-29 오전 11.11.04.png

First found an image you like, and transform the size in photoshop.

Then go to

http://www.appicon.build

You can get an app icon from there.

스크린샷 2016-03-29 오전 11.15.22.png

Then you’ll have this folder.

스크린샷 2016-03-29 오전 11.16.00.png

Go to Assets.xcassets, and drag the Appicon.appiconset folder.

스크린샷 2016-03-29 오전 11.17.18.png

Now you got an app icon! Easy Peasy.

스크린샷 2016-03-29 오전 11.40.33.png

The code :

//

//  ViewController.swift

//  RGBslider1212200

//

//  Created by 서예정 on 2016. 3. 15..

//  Copyright © 2016 YeJung. All rights reserved.

//

//import the UIKit library

import UIKit

//create a class for the ViewController

class ViewController: UIViewController {

    

    

    //create variables to hold slider values

    

    @IBOutlet weak var redSlider: UISlider!

    @IBOutlet weak var greenSlider: UISlider!

    @IBOutlet weak var blueSlider: UISlider!

    

    

    //create variables for the text labels

    @IBOutlet weak var redLabel: UILabel!

    @IBOutlet weak var greenLabel: UILabel!

    @IBOutlet weak var blueLabel: UILabel!

   

    

    //create a variable for the colorPatch

    

    @IBOutlet weak var colorPatch: UIView!

        

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

        // call the updateColor fuction to set the initial color.

        updateColor(redSlider)

    }

    

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

    

    //create a function that update the color when the slider is moved

    @IBAction func updateColor(sender: AnyObject) {

   

        //create variables to hold the slide values

        let redColor = CGFloat(redSlider.value)

        let greenColor = CGFloat(greenSlider.value)

        let blueColor = CGFloat(blueSlider.value)

        

        //map the slider values from 0 -> 1 to 0 -> 255

        let redMapped = Int(redColor*255)

        let greenMapped = Int(greenColor*255)

        let blueMapped = Int(blueColor*255)

        

        //send the value to the text field

        redLabel.text = String(\(redMapped)”)

        greenLabel.text = String(\(greenMapped)”)

        blueLabel.text = String(\(blueMapped)”)

                

        //set the background color

        //view.backgroundColor = UIColor(red: redColor, green: greenColor, blue: blueColor, alpha: 1)

        

        colorPatch.backgroundColor = UIColor(red: redColor, green: greenColor, blue: blueColor, alpha: 1)

    }

    

    @IBAction func resetPressed(sender: AnyObject) {

        redSlider.value = 0.5

        greenSlider.value = 0.5

        blueSlider.value = 0.5

        updateColor(redSlider)

        

    }

    

    //end of class

}

The Dropbox Link :

https://www.dropbox.com/s/m39txvcgzby5z31/0329RGBSliderhw_1212200.zip?dl=0

 

 

 

 

IMD 1_Xcode RGB Slider 2

This is second class of making RGB Slider. Last time I’ve failed to simulate because of an error. Now I know why that error was happened.

스크린샷 2016-03-22 오전 12.24.55

I solved this error by connecting outlet line again.

We can also change the size of simulator. Go to Window>Scale.

스크린샷 2016-03-28 오후 6.34.42.png

If you have some error of naming, just delete the label box, and create new one.

And if you have a Blue Arrow, you have to remove it. Because that can cause some error.

Just drag and drop anywhere to remove that blue arrow.

You can drag the line opposite way, too.

I’ve made green and blue to move same with red.

스크린샷 2016-03-22 오전 11.31.58.png

And to set background color. This is the code needed.

view.backgroundColor = UIColor(red: redColor, green: greenColor, blue: blueColor, alpha: 1)

스크린샷 2016-03-22 오후 12.16.08.png

Then we can see this.

스크린샷 2016-03-22 오후 12.12.38.png

Wow, almost done with our RGB Slider. Now I will bring color patch from the filter.

스크린샷 2016-03-22 오후 12.22.43.png

Search ‘view’ and drag it to your screen. And now we will gonna add some code.

colorPatch.backgroundColor = UIColor(red: redColor, green: greenColor, blue: blueColor, alpha: 1)

스크린샷 2016-03-22 오후 12.27.07.png

Instead of View, we changed to colorPatch. Now our RGB Slider is finished!

My Code :

//

//  ViewController.swift

//  RGBslider1212200

//

//  Created by 서예정 on 2016. 3. 15..

//  Copyright © 2016 YeJung. All rights reserved.

//

//import the UIKit library

import UIKit

//create a class for the ViewController

class ViewController: UIViewController {

    

    //create variables to hold slider values

    

    @IBOutlet weak var redSlider: UISlider!

    @IBOutlet weak var greenSlider: UISlider!

    @IBOutlet weak var blueSlider: UISlider!

    

    //create variables for the text labels

    @IBOutlet weak var redLabel: UILabel!

    @IBOutlet weak var greenLabel: UILabel!

    @IBOutlet weak var blueLabel: UILabel!

    

    //create a variable for the colorPatch

    

    @IBOutlet weak var colorPatch: UIView!

     

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

    }

    

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

    

    //create a function that update the color when the slider is moved

    @IBAction func updateColor(sender: AnyObject) {

   

        //create variables to hold the slide values

        let redColor = CGFloat(redSlider.value)

        let greenColor = CGFloat(greenSlider.value)

        let blueColor = CGFloat(blueSlider.value)

        

        //map the slider values from 0 -> 1 to 0 -> 255

        let redMapped = Int(redColor*255)

        let greenMapped = Int(greenColor*255)

        let blueMapped = Int(blueColor*255)

        

        //send the value to the text field

        redLabel.text = String(\(redMapped)”)

        greenLabel.text = String(\(greenMapped)”)

        blueLabel.text = String(\(blueMapped)”)

             

        //set the background color

        //view.backgroundColor = UIColor(red: redColor, green: greenColor, blue: blueColor, alpha: 1)

        

        colorPatch.backgroundColor = UIColor(red: redColor, green: greenColor, blue: blueColor, alpha: 1)           

    }

    //end of class

}

스크린샷 2016-03-22 오후 12.27.50.png

Isn’t it awesome?

After this class, I’ve changed some interface. Check this out.

스크린샷 2016-03-28 오후 6.28.09.png   스크린샷 2016-03-28 오후 6.27.56   스크린샷 2016-03-28 오후 6.26.55

So beautiful. I really like it. So this is end of my work! My First RGB Slider~

My Dropbox Link :

https://www.dropbox.com/s/roy4cda6zmpl06a/RGBSliderhw_1212200.zip?dl=0

DMC 1_Adding audio

We’ve learned how to put the audio in the object.

First, I downloaded audio.zip from our DMC 1 blog.

Before you import the audio, create an folder named ‘audio’ inside assets.

스크린샷 2016-03-21 오전 10.30.58

And you can just drag and drop the audio inside that folder.

스크린샷 2016-03-21 오전 10.33.44.png

Select the object you want to put an audio, and click ‘Add Component’.

스크린샷 2016-03-21 오전 10.34.05.png

 

 

스크린샷 2016-03-21 오전 10.34.54.png

Then you can see that screen. Choose ‘Audio Source’.

스크린샷 2016-03-21 오전 10.47.00.png

Click the little circle next to AudioClip, and choose the sound you want to put in.

Make sure to check ‘Play On Awake’ and ‘Loop’. It will make your sound awake and loop.

If you want to hear your sound when you get closer, then move Spatial Blend bar to 3D area. The sound gets wider when we go closer. You can also change some details down at ‘3D Sound Settings’.

스크린샷 2016-03-21 오전 11.06.06.png

‘Max Distance’ is about your sound’s range. You can set your sound’s maximum distance.

You have to choose Custom Rolloff. (Volume Rolloff > Custom Rolloff)

Yes, now we are ready to play.

스크린샷 2016-03-26 오후 8.37.11.png

I’ve add some other sounds to my zombies and idols.

If you find something to change, click ‘play’ button again. Not ‘pause’ button.

And now we are going to export this file to share with other people.

Go to assets > Export Package.

Save it to your dropbox. And when you open the export package, you can do it like this.

스크린샷 2016-03-21 오전 11.41.24.png

My Dropbox Link :

https://www.dropbox.com/s/exi7rxkw1ktq7ix/MyFirstWorld_1212200.unitypackage?dl=0

 

IMD 1_Xcode RGB Slider

In this class, we will learn a program named ‘Xcode’. We can make an application with this program. I’ve learned how to make a ‘RGB Slider’ in first class.

First, if you open the ‘Xcode’. You will see this.

스크린샷 2016-03-21 오후 9.21.34.png

We will create a new Xcode project, so choose second one.

스크린샷 2016-03-15 오전 10.44.39

Make sure do not have any space in your product name.

And save it to the Dropbox. (Do not check git)

We will going to make a RGB Slider. Search a slider and drag it to the Main storyboard.

스크린샷 2016-03-21 오후 11.03.22.png

스크린샷 2016-03-21 오후 11.09.01.png

Transform its length. And we need a Label for Red, Green, Blue.

스크린샷 2016-03-21 오후 11.11.42

 

 

 

 

 

Now we will going to make three of them.(R,G,B)

You can duplicate by ‘option key’.

스크린샷 2016-03-21 오후 11.49.45.png

And we will add some code.

스크린샷 2016-03-21 오후 11.55.45

Click the crossed circle, than you’ll have coding screen.

 

스크린샷 2016-03-21 오후 11.57.58.png

스크린샷 2016-03-22 오전 12.19.51.png

//

//  ViewController.swift

//  RGBslider1212200

//

//  Created by 서예정 on 2016. 3. 15..

//  Copyright © 2016 YeJung. All rights reserved.

//

//import the UIKit library

import UIKit

//create a class for the ViewController

class ViewController: UIViewController {

    //create variables to hold slider values

    @IBOutlet weak var redSlider: UISlider!

    

    //create variables for the text labels

    @IBOutlet weak var redLabel: UILabel!

    

    

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

    }

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

    //create a function that update the color when the slider is moved

    @IBAction func updateColor(sender: AnyObject) {

    

        //create variables to hold the slide values

        let redColor = CGFloat(redSlider.value)

        

        

        //map the slider values from 0 -> 1 to 0 -> 255

        let redMapped = Int(redColor*255)

        

        //send the value to the text field

        redLabel.text = String(“\(redMapped)”)

        

        //set the background color

    

    }

    

//end of class

}

This is our code. If you want to add an outlet, you can drag pushing control key.

And when you want to add an action, you should change outlet > Action.

When you finish, you can just click the play button, than you’ll have an simulator.

스크린샷 2016-03-22 오전 12.24.55.png

When I was in class, it worked well.

But now when I do it again by myself, I got an error… T.T   So sad.

I’ll fix this next class.