ToDo

  • Finish creating the Reference class images for iPad (maybe set of scaled so-so images to test on iPhone later)
  • Research the round button issue – how do I want to handle drawing circles around faces, etc.
  • Start blocking out where code has to go at high level. Probably got through the Mac source and make some decisions and type stubs in either GossipViewController or DrawingView
  • What’s the best way to track what I have and haven’t brought over from the Mac source code?

Next Steps

  • Create a static Resources class and populate it with the so-so character images, and draw these images to the iPad screen – DONE
public static UIImage Bara_soso { get { return UIImage.FromFile("_Resources/Faces/so-so/Bara.png"); } }
public static UIImage Owen_soso { get { return UIImage.FromFile("_Resources/Faces/so-so/Owen.png"); } }
public static UIImage Max_soso { get { return UIImage.FromFile("_Resources/Faces/so-so/Max.png"); } }
public static UIImage Ella_soso { get { return UIImage.FromFile("_Resources/Faces/so-so/Ella.png"); } }
public static UIImage Mort_soso { get { return UIImage.FromFile("_Resources/Faces/so-so/Mort.png"); } }
public static UIImage Zoe_soso { get { return UIImage.FromFile("_Resources/Faces/so-so/Zoe.png"); } }
  • See how to handle taps detected in the DrawingView in the GossipViewController (where all the non-graphics code should be) – DONE

Create a property in the DrawingView for the GossipViewController reference:

public GossipViewController gvc { get; set; }

And set it in the GossipViewController’s constructor:

DrawingView drawView = (DrawingView)this.View;
drawView.gvc = this;

In the DrawingView you use the GossipViewController reference to access any public GVC methods.

public void MethodInDrawingViewThatDetectsTaps()
{
    gvc.MethodInGossipViewControllerThatHandlesTaps();
}
  • See how to handle calls to the DrawingView from the GossipViewController to update the screen based on calculations, etc. – DONE

In the GossipViewController get a reference to the DrawingView (which is set as the UIViewController’s view).

DrawingView drawView = (DrawingView)this.View;

Then you can call any public (or protected?) methods in DrawingView using this reference.

drawView.MethodInDrawingViewThatUpdatesAnImage();

The question is whether to use Chris’ data structures verbatim, accessing images like he does via the pre-populated ImagePlusLocation array, or access individual images as objects (see below).

Replicating Chris’ way would speed up porting of the Mac source. But then I’d probably need a second array for images shrunk down for the iPhone (or come up with some scaling on the fly.

I don’t want to have a second array of images (which I’d have to create myself) so I’m going to do scaling on the fly. If I do scaling on the fly I might as well include it in the images Get code.

I probably wouldn’t have to have a second array of images, I merely populate them with the appropriately scaled image at the start of the game.

Image naming conventions

Bara_adorable - for iPad
Bara_adorable_32x32 - for iPhone

Referenced using

names[ i ] + “_” + affinityLevelText[ j ] + device = iphone ? “_32x32” : “”

Both images created from /Faces/adorable/Bara.png. The iPad image Get

return UIImage.FromFile(“_Resources/Faces/adorable/Bara.png”)

The iPhone image Get

return UIImage.FromFile(“_Resources/Faces/adorable/Bara.png”).Scale(new SizeF(32f, 32f));

How does Chris handle recalling different states of same character images – Bara-Nice vs. Bara-Nasty?

Now I know why the directory names under Faces are lowercase – Chris is populating the appropriate faces[ i ] [ j ] cell by building an absolute path to the specific image, referenced by affinityLevelText[ j ] and names [ i ]. Since the text in affinityLevelText[ j ] is displayed onscreen at the end of a sentence it’s in lowercase.

ImagePlusLocation[][] faces=new ImagePlusLocation[maxCharacters][cAffinityLevels+1];

for (int i=0; (i<maxCharacters); ++i) {
    for (int j=0; (j<cAffinityLevels+1); ++j) {
        faces[i][j]=new ImagePlusLocation(readImage("Faces/"+affinityLevelText[j]+"/"+names[i]));
        faces[i][j].setLocation(x,y);
    }
}

At runtime I can detect what device I’m running on in DrawView. Great! Hopefully I’ll be able to take appropriate action in GossipViewController in DrawView.

if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)

Good link on using resources in MonoTouch – Resources in MonoTouch Assembly. Good technique to access images as objects.

public static UIImage XamarinLogo {
    get {
        return UIImage.FromFile("_Resources/Xamarin_Logo.png");
    }
}

Primary benefit would be to be able to transform an image before displaying it (which I’ll probably have to do depending on which device I’m running on).

public static class Resources
{
    public static UIImage XamarinLogo {
        get {
            return UIImage.FromFile ("_Resources/Xamarin_Logo.png");
        }
    }

    public static UIImage XamarinLogo_32x32 {
        get {
            return UIImage.FromFile ("_Resources/Xamarin_Logo.png").Scale (new SizeF (32f, 32f));
        }
    }
}

Like the scaling within the Get. Could have BaraNice_iPad and BaraNice_iPhone; use appropriate depending on device.

Funny how the simple things always frustrate you. Added old DrawingView code to test out Core Graphics routines in iPhone and iPad simulator. Kept getting message “Unknown class DrawingView in Interface Builder file.” Turns out the file’s build action was set to Content instead of Compile (usually it’s the other way, I forget to set the build action of content files to Content).


Finally got around to creating a complete Universal solution for Gossip iOS. Figuring out today the best way to draw on iPhone and iPad screen sizes detected at runtime.


Made one line change to source that Chris sent on 02.24.13.

This entry was posted in Side Projects and tagged . Bookmark the permalink.