Spare Code ? Dump It here.

1181921232427

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, PRO, Bowlboy Sidekick Posts: 9,271

    Spawn Actors Centered in the Scene

    In this demo, I show you how to easily spawn actors centered on the screen. The best part? It works for how ever many actors you want. They will always spawn centered on the screen with an equal gap between each. Everything is customizable: from how many actors you want spawned, the gap size between each, the size of the actors, and so forth. Enjoy!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Display Table Contents / Looping Table Display

    Here is a fun little example of how to display the contents of a table. Its sort of like a UIPicker. It also shows how to loop the end of the table back to the beginning so you can just keep scrolling and scrolling and scrolling .....

    Download here: http://www.mediafire.com/download/dz1x77wbhwtfjky/LoopingTableDisplay.zip

  • Braydon_SFXBraydon_SFX Member, Sous Chef, PRO, Bowlboy Sidekick Posts: 9,271

    Hey everyone,
    Here is a new snippet of code I whipped up today:
    In this demo, I show you how to randomly choose 3 unique numbers without removing rows in a table. Then, I show you how to use that data to spawn 3 actors on screen.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited November 2014

    @Braydon_SFX said:
    Hey everyone,
    Here is a new snippet of code I whipped up today:
    In this demo, I show you how to randomly choose 3 unique numbers without removing rows in a table. Then, I show you how to use that data to spawn 3 actors on screen.

    While I was wondering how you achieved that without a table, I thought of a way to pick random values without a table by using text string functions. It's not terribly useful considering it is limited to nine values but it could easily be adjusted to work with at least 26 (alpha characters).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    I recently made this for another person on the forums. I don't know if this could be of any use to someone else, but I thought I would go ahead and post it anyways. It is a tutorial for fading in and out of scenes. The rules work so that you can go back and forth between the scenes endlessly.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879
    edited December 2014

    I am beginning a children's game on telling time. I got to thinking about how difficult it is for developers to translate between a 360 degree coordinate system, a 12 hour clock, and a 60 minute clockface. That all gets messy.

    Anyway this implementation uses an overall angle to tell time. The angle can go from 0 to 4320 (which is 12x360). The clock hands are based upon the overall angle.

    Someone might find this way of making a 12 hour clock easier than the usual methods. (I think I do.)

    http://www.mediafire.com/download/eqbdt467xl65ro5/Clock4320.zip

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Remember Actor Positions After Changing Scene

    Several people have asked for this so here it is. It allows you to drag an actor to a new position and then change scenes. When you return to the initial scene, the actor's position "remembers" where it had been dragged to.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • sswisehauptsswisehaupt Member, PRO Posts: 76

    What if I have three or four of the exact same actor(square in your example).

  • ArmellineArmelline Member, PRO Posts: 5,327

    Quick little demo that shows two things. Not sure if they've been posted before - I've not been keeping up with my tracking of this thread in the past couple of months, been too busy :(

    The first is a formula to calculate the number of days in a month, given the number of the month (i.e. Jan = 1, Dec = 12). No leap years taken into account though.

    The formula isn't mine, I just stuck it in GameSalad. The formula itself (in Javascript) is:

    function f(x) { return 28 + (x + Math.floor(x/8)) % 2 + 2 % x + 2 * Math.floor(1/x); }

    The second thing is a way of incrementing a number up to a given value then repeating from 1 again. So if you need a button to add 1 to a number until it reaches 10, and then reset to 1 etc. this will achieve that goal (using game.Value for the number and game.Top for the highest number to be allowed):

    max(1,((game.Value+1)%game.Top+1))

    Both can be seen in the attached demo. Perhaps someone can improve upon the latter formula, I just threw it together now for this demo but it seems to work. It's too simple for me to believe someone hasn't previously posted it though :D

  • colandercolander Member Posts: 1,610

    I asked @Armelline if it was ok to add and post his project with leap years. He's cool with it so here it is.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2014

    @Armelline, here's another way to do this, assuming that game.Value starts at 1 (or any value from 1 to game.Top):

    Change Attribute game.Value to (game.Value%game.Top)+1

    GS Staff have said that the '%' symbol won't be supported for long so they recommend this instead:

    Change Attribute game.Value to mod(game.Value,game.Top)+1

    Note: the mod() or % function confuses many people. I'm not directing this at you but rather at people who might be reading this and are new to the modulo function in math. Mod() returns the remainder after a division operation. So mod(5,2) is the same as saying "What is the remainder when you divide 5 by 2?" The answer is one. And mod(8,10) would be eight since ten doesn't go into eight even once. The reason we use the mod() function to loop values in this way is because remainders look like this when dividing by 10, for example:

    1%10=1
    2%10=2
    3%10=3
    4%10=4
    5%10=5
    6%10=6
    7%10=7
    8%10=8
    9%10=9
    10%10=0

    If you add one to the result of each modulo operation, you get this:

    1%10=1+1=2
    2%10=2+1=3
    3%10=3+1=4
    4%10=4+1=5
    5%10=5+1=6
    6%10=6+1=7
    7%10=7+1=8
    8%10=8+1=9
    9%10=9+1=10
    10%10=0+1=1

    Those answers are what we want because we want the result for each case to be one higher than the starting value except when we reach 10... for that we want the result to be 1 so that the counting loop starts over again.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • robertkdalerobertkdale USAMember Posts: 912

    Thank you!

    Big Smile Games Play Happy!
    Check out our other GameSalad exclusives.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2014

    Custom Font For Letters

    I decided to build a proof-of-concept demo that provides a method for displaying a custom font from a text string (attribute). It's far from polished but I think it might be viable for someone who really needs to do this and isn't too picky about aesthetics. Of course, it would be easier to program and look better with a fixed-width font but I intentionally used one that wasn't in order to show how it might work with any font.

    Font size and color are adjustable to set values but could certainly be altered to allow for any values (e.g. a size slider). My choice of labels ("12," "24," "36") was mostly arbitrary and doesn't match actual font point sizes.

    The font character images were made in Illustrator CS6 and I am including those files. The underscore prefix for lowercase letters was needed to make the filenames unique.

    Note: made with Mac Creator 0.12.10.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • zweg25zweg25 Member Posts: 738
    edited December 2014

    Quick custom keyboard (Project Size 5kb)

    If you are in need of a delete button you will have to add to this, but its a good start for a custom keyboard.

    Best,

    zweg25

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @Zweg25 -- nice! Thanks for sharing with the community.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Random number generator that allows repeats

    This is a simple demo that allows repeated random numbers to trigger a rule. So if random(1,3) returns 1, 2, 3, 3, or a similar sequence, normally the repeated value would not trigger a When game.random=3 rule the second time through.

    See the note in the actor for more details.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @LumpApps said:
    Time for me to do some community love. Here is a proto for making a game with trams or whatever following a track you build on the fly.

    Fantastic !!

  • LumpAppsLumpApps Member Posts: 2,880
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Here is a Scrolling Menu System I've thrown together using the Fast Constrain file as a base.

    I posted this in the Fast Constrain thread too, but thought I'd drop it here as well.

    Download it!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @tatiang said:
    Random number generator that allows repeats

    I finally get it!
    I kept thinking you were showing how to make random numbers that don't repeat. But in your example they obviously do!
    Then I thought you were making random numbers that do repeat and I said to myself, "What gives? Random numbers can often repeat. 'Nutun special about that!"
    Now I realize what you mean. If the random number is "3" then a rule only fires once for the "3". If it randomly comes up a "3" again (by random chance), then GameSalad won't re-fire the rule because the random number needs changes to some other value first.

    Yours' is a very nice solution to the 'unchanged condition' conundrum. Thanks for sharing this!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @jamie_c‌ -- Nice demo! Very handy!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Thanks @RThurman! Sorry I didn't explain it better. :\

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    Custom Font for Numbers

    Normally, custom fonts are displayed by constraining an actor's self.Image to a complicated mathematical expression that is both hard to understand and easy to get wrong when entering it. It often looks something like this:

    floor(( game.Score %100000)/10000)

    And, each digit actor requires a slightly different expression.

    This demo attempts to simplify things. It uses a loop and a little trick I discovered: because integers can be converted to text, text string functions can be used to manipulate the individual digits as if they were characters in a string.

    For fun, I decided to spawn the digits instead of placing them and manually changing their self attributes to reference their position in the number (e.g. the 3rd digit has to know it's in the 3rd position). The downside of this is that it spawns only the number of digits in the original game.score attribute. Once the score increases and requires additional digits, it won't spawn new digits. Edit: by some random luck, it actually spawns new digits when needed. Holy smokes! I didn't even mean to do that.

    There's also a timer that simulates score increases.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    @tatiang said:
    Thanks RThurman! Sorry I didn't explain it better. :\

    Your explanation was just fine. :)
    My misinterpretation has more to do with my expecting to be reading about something else.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879
    edited January 2015

    @tatiang said:
    Custom Font for Numbers

    Great solution! Thanks!

    Edit: The thought just occurred to me that you could probably apply kerning to the number string if you position the digits according to their image widths.

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    @jamie_c said:
    Here is a Scrolling Menu System I've thrown together using the Fast Constrain file as a base.

    I posted this in the Fast Constrain thread too, but thought I'd drop it here as well.

    Download it!

    I've been looking for this exact menu system for a while now. Much appreciated!

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    @MattButlerStudios, cool, glad you found it then! :) That was only possible thanks to @Socks 'fast constrain' example.

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    Here is a Fireworks test project I made awhile ago for fun. It's not the most efficient code, and a few of these types of templates exist already. But I do love the effects it gives.

    Follow us: Twitter - Website

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Nice, @AlchimiaStudios‌. I especially like the little "chasers" that scurry around on one of the effects. Reminds me of my wife's favorite fireworks.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    @tatiang said:
    Nice, AlchimiaStudios‌. I especially like the little "chasers" that scurry around on one of the effects. Reminds me of my wife's favorite fireworks.

    Thanks! Yeah I think I made this around 4th of July after going to a Fireworks show and the goal was to emulate some of the effects. Those scurry ones are some of my favorite types too.

    Follow us: Twitter - Website

Sign In or Register to comment.