Skip to content

New extension: Carousel Behavior #2282

Description

@NicolasDemangeat

Description

Adds a Carousel behavior that turns sprites object with animations into a looping, sliding carousel item.

Calling Next() or Previous():

  1. Smoothly tweens the current item off-screen
  2. Switches to the next or previous animation index
  3. Tweens the new item back into view

Configurable properties (visible directly in the Scene Editor, per instance):

  • MinIndex / MaxIndex : the range of animation indexes to cycle through
  • Loop : wrap around at the ends instead of stopping
  • SlideDistance : how far the item slides off-screen
  • Duration : how long each slide takes, in seconds

The Tween behavior is required and added automatically when Carousel is added to an object (nothing extra to set up).
Can work with the swipe gesture extension.

How to use the extension

Put the Carousel behavior on a sprite with multiple animations to build:

  • A level-select screen, cycling through level previews
  • A character or skin picker
  • Any settings screen cycling through a small set of choices (difficulty, region, theme...)

Setup:

  1. Set MinIndex and MaxIndex to match the number of animations on your object (0-based: the first animation is index 0)
  2. Enable Loop if the carousel should wrap around at the ends
  3. Call Next() / Previous() from your arrow buttons
  4. Read CurrentIndex() to update the rest of your UI (labels, lock icons, star ratings...)
  5. Use IsBusy() to know if the Carousel is playing tween.

Checklist

  • I've followed all of the best practices.
  • I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
  • I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.

AI usage

  • I used an AI to generate some part of the code.
  • I don't understand the generated code or I don't feel able to modify it.

Example file

Carousel-example.zip

Extension file

Carousel.zip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions