The effect is that the mouse touch, move, always have pictures to go along with such use what technology ah, thank you!!
Reply:
There is a moveto event ah you realize that events can be friends
Reply:
Remember correctly, the above should be this you refer to
- (Void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
UITouch * touch = [touches anyObject];
lastTouch = [touch locationInView: self];
if (shapeType == kImageShape) {
CGFloat horizontalOffset = drawImage.size.width / 2;
CGFloat verticalOffset = drawImage.size.height / 2;
redrawRect = CGRectUnion (redrawRect,
CGRectMake (lastTouch.x - horizontalOffset,
lastTouch.y - verticalOffset,
drawImage.size.width,
drawImage.size.height));
}
else
redrawRect = CGRectUnion (redrawRect, self.currentRect);
redrawRect = CGRectInset (redrawRect, -2.0, -2.0);
[Self setNeedsDisplayInRect: redrawRect];
}
- (Void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event {
UITouch * touch = [touches anyObject];
lastTouch = [touch locationInView: self];
if (shapeType == kImageShape) {
CGFloat horizontalOffset = drawImage.size.width / 2;
CGFloat verticalOffset = drawImage.size.height / 2;
redrawRect = CGRectUnion (redrawRect,
CGRectMake (lastTouch.x - horizontalOffset,
lastTouch.y - verticalOffset,
drawImage.size.width,
drawImage.size.height));
}
redrawRect = CGRectUnion (redrawRect, self.currentRect);
[Self setNeedsDisplayInRect: redrawRect];
}
Reply:
- (Void) ccTouchMoved: (UITouch *) touch withEvent: (UIEvent *) event
{
/ / Get the touch point position
CGPoint touchLocation = [self convertTouchToNodeSpace: touch];
/ / Get the last touch point position
CGPoint oldTouchLocation = [touch previousLocationInView: touch.view];
oldTouchLocation = [[CCDirector sharedDirector] convertToGL: oldTouchLocation];
oldTouchLocation = [self convertToNodeSpace: oldTouchLocation];
/ / Get the vector between the two positions
CGPoint translation = ccpSub (touchLocation, oldTouchLocation);
attackPoint = touchLocation;
/ / TouchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];
if (selmagic.magiccdend)
{
selmagic.magic_ring.opacity = 250;
canmagic = YES;
/ / Contact position after moving
CGPoint newPos = ccpAdd (selmagic.magic_ring.position, translation);
/ / Let the wizard with the release of Magic movable contact moves
selmagic.magic_ring.position = newPos;
}
}
According to this method can be written
Reply:
ccTouchbegin ccTouchMoved Reset Wizard position
No comments:
Post a Comment