Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 8    Views: 131

Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
12/11/13 01:30 AM (11 years ago)

wobble! - quiz tweak for iOS

Did anybody else notice the sweet wobble image code that David snuck into the BT 3.0 core? I've been doing a lot of tinkering with the interactive quiz plugin and realized this block of code works great as feedback for incorrect answers. Read on if you want your quiz to wobble like the one in this video - https://www.dropbox.com/s/o0xv1r9hub83n08/wobbleVid.mov It's really easy actually - first add the line [self wobbleImage]; to the -(void)answerClick method in BT_screen_quiz.m. ( Picture for reference - https://www.dropbox.com/s/no1du677g5wxz45/Screen%20Shot%202013-12-10%20at%2011.19.55%20PM.png ) Next and final step - add this big block of code after the -(void)answerClick method (that means make sure it is OUTSIDE of any curly brackets) //wobbleImage... -(void)wobbleImage{ [BT_debugger showIt:self theMessage:@"wobbleImage"]; //animate the image... #define RADIANS(degrees) ((degrees * M_PI) / 180.0) //You can mess around with these numbers to adjust the wobble CGAffineTransform leftWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-2.0)); CGAffineTransform rightWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(2.0)); answerButtonBox.transform = leftWobble; [UIView beginAnimations:@"wobble" context:nil]; [UIView setAnimationRepeatAutoreverses:YES]; [UIView setAnimationRepeatCount:1]; [UIView setAnimationDuration:0.14]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(wobbleEnded)]; answerButtonBox.transform = rightWobble; answerButtonBox.transform = leftWobble; [UIView commitAnimations]; } //wobbleEnded... -(void)wobbleEnded{ [BT_debugger showIt:self theMessage:@"wobbleEnded"]; answerButtonBox.transform = CGAffineTransformIdentity; } picture for reference - https://www.dropbox.com/s/3ri8pvhsy3tl7uv/Screen%20Shot%202013-12-10%20at%2011.22.34%20PM.png that's it..just thought it was a cool little trick worth sharing. Let me know if there's any issues
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
12/11/13 02:20 AM (11 years ago)
I'll try that. Slick little idea! Cheers! -- Smug
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
12/11/13 05:00 AM (11 years ago)
Nice! Thanks
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
12/11/13 07:03 AM (11 years ago)
Great! Absentia, have you found any bugs that need to be addressed on the quiz plugin? I'm going to manage this one going forward.
 
tb
buzztouch Evangelist
Profile
Posts: 2050
Reg: Nov 03, 2011
Oxford
32,300
like
12/11/13 10:42 AM (11 years ago)
Slick!
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
12/11/13 11:04 AM (11 years ago)
@Chris - yeah, a couple..I'm heading out for some Christmas shopping right now but I'll follow up on it tonight
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
12/11/13 11:08 AM (11 years ago)
k cool
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
12/12/13 09:34 AM (11 years ago)
Agreed, great share/mod, thanks. It was a nice snippet he dropped in there to show you how easy it is to use CoreGraphics in your code. BT is full of nuggets like this if you explore the code. You can use this code in a 2.0 project as well if you want - the only thing you'll need to do is #import <CoreGraphics/CoreGraphics.h> into the .h of the class you want to use Core Graphics in. CG tricks are nice, cheap quick way to spice up a stale Company Logos.....
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
12/18/13 08:50 AM (11 years ago)
This has now been added to the interactive quiz plugin.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.