Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > how do I use a .tiff image to draw tetris shapes?

how do I use a .tiff image to draw tetris shapes?
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2002
Status: Offline
Reply With Quote
Mar 21, 2002, 06:53 PM
 
I am coding a tetris game in cocoa using Objective-c. I want to use some .tiff images of colored blocks to display the tetris shapes in a view. How do I display the images? I know how to draw shapes using NSBezierPath, but I can't seem to get this to work. I've seen a lot of stuff about NSImages, but no code showing me how to display the .tiff images at certain cordinates in a view. I would really appreciate it if someone could help me with a little tutorial or some sample code. Thanks in advance.

battlestone.
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Mar 21, 2002, 11:43 PM
 
This should be pretty easy to do using a simple adaption of some of the code posted in this thread about image scaling. It deals with locking focus on a view that you want to draw into and then telling an image to draw itself at a certain location there.

I will try to whip up some sample code for you if nobody else does tonight (I am a bit busy) but the general idea would be:
-load the tiff into an NSImage instance
-lock focus on your game field view
-tell the image to draw itself in the rect (some co-ordinates of where it should go) from the rect (its dimensions) using code similar to that mentioned in the link above
-unlock focus on the game field view

That should do it but I am not sure. Take a look at the other thread to see if you get the idea from there.

Hope that helps,
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:23 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2