Graphic Rotating 5 Point Star - Solved

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Graphic Rotating 5 Point Star - Solved

Post by DR White » Wed Aug 28, 2013 11:00 am

I am working on a simple Children's game in which I want to have a star starting small in the back of the screen and
becoming larger and rotating, to give the appearance of coming toward the student.

I have been successful in rotating a polygon with "revRotatePoly", but I cannot make a star from the polygon and therefore cannot rotate a star
(using an image does not have the quality effect that I am looking for).

Also, If possible I need to put different words in the star as it moves towards the student.

Is this possible in LiveCode?

Thanks,

David
Last edited by DR White on Thu Sep 19, 2013 2:56 am, edited 2 times in total.

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Graphic Rotating 5 Point Star

Post by dave_probertGA6e24 » Wed Aug 28, 2013 12:49 pm

Hi David,

The built in graphics tools at the moment don't have an easy way of making a star shape. But they are basically polygons with specific points set in their 'points' field - so the 'easy' way to do this is via some simple Maths.

I have attached an example of a star drawing function and animation thingy. Take a look - most all of it is commented and the code is all on the card script area (except for a single line in the button).

To do the text on top you would simply add a text field and reposition/scale it at the same time as drawing the star (in the 'tickTock' function I would suggest). If you need help with that then just let me know and I can make an example for you.

Hope this helps.

Cheers,
Dave
Attachments
ZoomStar.livecode.zip
(1.85 KiB) Downloaded 393 times
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Graphic Rotating 5 Point Star

Post by bn » Wed Aug 28, 2013 1:38 pm

Hi Dave,

what a beautiful example stack.

If David wants to display text I propose he sets the label of graphic theStar to his text by script (you can not set the label of a graphic in properties inspector) and set the showName of the graphic to true. Then add this to the script in the ticToc handler

Code: Select all

 // ---- increase the star size
   put round(osize * 1.05) into osize
   put osize div 10 into tTextSize -- added bn
   set the textSize of grc "theStar" to min(max(tTextSize,10),42) -- added bn
   // ---- change the star angle
it will increase the textSize from 10 (minimum) to 42 (max) depending on the size of the star

Kind regards
Bernd

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Graphic Rotating 5 Point Star

Post by dave_probertGA6e24 » Wed Aug 28, 2013 2:26 pm

Thankyou Bernd,

That's a nice simple addition to it for the text. I didn't know that the textsize of a label could be changed for a graphic - cool.

The only thing it would need too is this in the 'create' part in init:

Code: Select all

set the forecolor of it to 0,0,0
set the showName of it to true
Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Graphic Rotating 5 Point Star

Post by DR White » Wed Aug 28, 2013 10:18 pm

Dave P,

WOW!! Your ZoomStar stack is AWESOME!!! :D

I Love it when someone attaches the code.

Thanks VERY MUCH,

David W
Last edited by DR White on Wed Aug 28, 2013 10:22 pm, edited 2 times in total.

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Graphic Rotating 5 Point Star

Post by DR White » Wed Aug 28, 2013 10:20 pm

Bernd,

Thank you for putting the icing on the cake with the expanding text.

David W

Post Reply