 |
 |
Graphics examples?
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Location: San Luis Obispo, California, USA
Status:
Offline
|
|
Hi there.
I'm teaching my self how to code. I know some C and Java, and I'm trying to learn objective-C.
I've made some simple applets, and some extremely simple cocoa apps with java, and I've done both the currency and the temperature converter examples.
I want to make a simple game, but I'm starting small. I've messed around with NSImageView, and I've managed to toggle between two images by pressing a button.
I learn best by example, and I was wondering if anyone could send me some sample code of simply moving a sprite around using the keyboard? Java or Obj-c is fine. I've looked at "Blast-App" but it's too big for me right now.... I get lost looking at. I guess I'm looking for an example that is between currency convertor and blast-app.
I would really appreciate any help. Once I get up to speed at programming in X, I'll gladly repay anyone with help with their projects
Thanks,
Nathaniel
nbmartin@calpoly.edu
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Location: San Luis Obispo, California, USA
Status:
Offline
|
|
Can anyone give me a hint on how to move a sprite in an imageview? I've used setImageView, but that just puts a picture across the whole view.
How do I put a small image in a view, then move it around?
-Nathaniel
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
The easiest way is to subclass NSView and then either use NSBitmapImageRep and draw the image in the view repeatedly or use NSImage and composite it repeatedly. If you use a buffered view then you'll probably need to overwrite the old images with white or something, each frame, before drawing new ones or else you might leave a little trail.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jan 2001
Location: San Luis Obispo, California, USA
Status:
Offline
|
|
Ok... I'm a real beginner at this, so I have bunches of questions
How do I set where the bitmap will appear in the image view? (i.e., how do I tell it to be at (20,50) instead of in the center?
What is a buffered view?
If I constantly overwrite the old images with white each frame, wouldn't it make the sprite look transparent?
Thanks for your help,
-Nathaniel
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status:
Offline
|
|
as for how to use NSView sub-classes, I was playing with a little Tic-Tac-Toe game a while ago and you can grab the source here (although I did cheat a bit by drawing strings instead of bitmaps but you get the idea).
A buffered view draws its contents to the window manager's buffer so that it can be displayed without asking the application what is going on (makes for nice benefits like faster redraws plus you can still read/move your windows in a crashing application). I am not sure what the specific benefits or leaving it non-buffered are, however.
You will only make it look transparent if you clear the view after drawing and before waiting for input (or adding a delay). If you overwrite it with a mask at the right time, that suggestion will work perfectly.
Good luck,
Jeff.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|