Scale (Sprite object extension) (Behaviours)

0 favourites
  • 4 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Scale (Sprite object extension) — Now for sale in the Scirra Store!

    https://www.scirra.com/store/construct2-behaviours/scale-sprite-object-extension-3878

    <h3>What you buy here?</h3><div class="deshr"></div>

    • Scale behavior for C2 and C3
    • Capx example

    <h3>What is Scale behavior?</h3><div class="deshr"></div><p>It's a behavior dedicated for Sprite objects which lets you set, get and compare current Sprite's scale.</p><h3>How is it different than using the normal scale?</h3><div class="deshr"></div><p>The difference is that Sprite object does not have the Scale expression at all so you can't read the current scale. </p><p>With this behavior you can set/get/compare 6 type of scales:</p><p>* General scale (by self)</p><p>* Width scale (by self)</p><p>* Height scale (by self)</p><p>* General scale (by image)</p><p>* Width scale (by image)</p><p>* Height scale (by image)</p><p>By self - means that it's a scale based on the initial Sprite size (the dimensions of the instance at it's creation are considered as scale = 1).</p><p>By image - means that it's a scale by the Sprite's image/texture size (the image dimensions are considered as scale = 1.</p><h3>Features</h3><div class="deshr"></div>

    • 6 types of scales to cover any project needs,
    • Extension to the most commonly used object type - Sprite,
    • Built-in Actions, Conditions & Expressions for all 6 scales manipulation,
    • Super light-weight (nothing is calculated per tick, calculations only on demand)

    <h3>Warranty</h3><div class="deshr"></div><p>This plugin does not rely on any third party libraries so it will never get outdated or broken. </p><p>Note that all of my plugins work with all platforms (including Cocoon Canvas+) unless described otherwise in the description.</p><p>I'm a full time programmer, in case of encountering any issues, please send me an email, I'll fix it ASAP!</p><h3>Want to be notified about updates?</h3><div class="deshr"></div><p>Join my Discord server: discord.gg/cjEg45m%3C/p%3E

    Use this topic to leave comments, ask questions and talk about Scale (Sprite object extension)

  • Sprite.Width / Sprite.ImageWidth = Width Scale

    Sprite.Height / Sprite.ImageHeight = Height Scale

    ((Sprite.Width / Sprite.ImageWidth)+(Sprite.Height / Sprite.ImageHeight)) / 2 = average scale.

    People really need a custom plugin/behaviour for such a basic math logic...?

    Not hating on your plugin of course, so don't be offended.

  • Sprite.Width / Sprite.ImageWidth = Width Scale

    Sprite.Height / Sprite.ImageHeight = Height Scale

    ((Sprite.Width / Sprite.ImageWidth)+(Sprite.Height / Sprite.ImageHeight)) / 2 = average scale.

    People really need a custom plugin/behaviour for such a basic math logic...?

    Not hating on your plugin of course, so don't be offended.

    Hi Niespor,

    Your math skills are really impressive, but I encourage you to take a closer look at the ACEs of the behavior as it covers much more than what you tried to calculate above.

    Your example shows how to calculate the current scale by its image. Which is also covered in the behavior but it's not very useful in the majority of projects.

    What's useful is the scale by the initial size of the sprite (not image), which is not covered in C2.

    Let's say you want to enlarge the sprite by 10% when you click on it and then revert it back to original size when you release the button. With C2 you'd have to save the original width and height of the sprite to some variables. Then calculate 110% for height and width and then use saved data to revert the size to original... which is quite a lot of work as for such a simple thing.

    With Scale behavior you just use one action and set scaleBySelf to 1.1 and then to 1.

    There are obviously many more use cases than that.

    Thank you for your interest in Scale behavior!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • [quote:s8spzlel]What's useful is the scale by the initial size of the sprite (not image), which is not covered in C2.

    Sorry for the noob question here, but what's the difference? Isn't sprite an image? Can you show me an example? Thanks.

    There is the "size" property, that says "The width and height of this object instance, in pixels".

    EDIT

    Watched the video, it clarifies everything. Neat behavior for objects that change size.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)