Updating only parts of the screen

Posts: 608
Joined: 2002.04
Post: #1
In my current project (which uses Cocoa) I am trying to make it only update the part of the screen that needs updating. So what I do is use NSUnionRect to get the rect of where the sprite was and where the sprites is. I use NSRectFill to clear that area and then use [backgroundImage compositeToPoint:spritePoint fromRect:unionOfSprite operation:NSCompositeSourceOver]. This greatly speeds it up (adds about 50 frames) but there is a white box around the sprite, as if the background didn't copy to all of the rect. Did I make sense? Anyone know what I am doing wrong? Where can I find examples of only updating parts of the screen?
Quote this message in a reply
Posts: 469
Joined: 2002.10
Post: #2
First off, I'd suggest not using cocoa quartz.*|
If I understand correctly, you're doing the following:
NSRectFill() to erase the sprite and it's new location.
[NSImage compositetopoint] to fill the erased rect with background.
then finally, [NSImage compositetopoint] to draw your sprite.
if this is the case, then your last sprite composite is probably not copying with alpha transparency. So what you need to do is make sure the NSImage you're drawing has a valid alpha and that you're using the right compositeop. Using disolve to point draws alpha transparency by default, I think; you might want to try that.

If you eventually find (as I did) that Cocoa and Quartz are too slow, might I suggest my SDK? <shamlessplug> http://www.variableaspect.com/experiments/CocoaBlitz </shamelessplug>

15.4" MacBook Pro revA
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  updating to ios5 recorder doesn't work anymore sefiroths 3 5,884 Nov 21, 2011 03:56 AM
Last Post: sefiroths
  About object creation, updating, interactions, Unity Najdorf 26 16,622 Jan 12, 2010 04:40 PM
Last Post: AnotherJake
  Updating Map Annotations - coordinates PHANTOMIAS 0 3,696 Dec 8, 2009 08:39 AM
  Browser Based.. Updating turn times? guest_05 1 4,316 May 24, 2007 04:03 PM
Last Post: Tobs_
  Parts of C++ not linking properly? Jones 15 9,521 Jun 22, 2006 11:12 AM
Last Post: Jones