How do I push other sprite outside of layout? And bring them back at their last position?

0 favourites
  • 11 posts
From the Asset Store
Push the Box Puzzle Game likes Sokoban made with Illustrator
  • So what im trying to do is

    When i click sprite 2, sprite 1 will move up out until it outside layout and sprite 3 and 4 will move down until it outside the layout.

    And when i click sprite 2 back the sprite that outside the layout will come back at their last position

    Same goes if i click the other sprite, the sprite that on top of it will move up and the sprite below it will move down.

    I know i can achieve this with bullet or litetween behavior but i have more than 100 sprite so pls help me what is the efficient ways to do it.

    Can i use litetween over 100 sprites? Can it give lag to mobile phone?

  • Yeah, LiteTween or Tween is probably the easiest way, plus you can select a nice easing effect. On click pick all sprites above, set tween target to self.y-1000, pick all sprites below, set tween target to self.y+1000. On second click bring them back (in LiteTween you can use "reverse" action).

    100 objects with tween should not be a problem even on mobile.

  • Use instances, not object types.

    Yes, you can have 100+ instances using Tween.

    Implementation example

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Kyatric what u mean by use instance not object types? U mean instance variables?

  • See the first link Kyatric posted. You should create 1 sprite object and add 100 instances (copies) of it to the layout. Not 100 different sprite objects!

  • But each sprite have different design different colours and diferent name on it

  • Set different animation, or different animation frame for each instance.

    You can of course have 100 objects if you like, it's up to you. In this case you will need to add them to one family.

  • Which one is better?

    1 sprite = 100 animations frames

    Or 100 sprite objects ?

  • Which is better - 1 horse or 100 chickens? :)

    It depends on your project, on how you use these sprites etc.

    If these sprites serve the same purpose (for example all are buttons), have similar properties, behaviors, then it's better to keep them as 100 frames in one sprite object.

    But there may be exceptions, for example if the images are big, one sprite with 100 frames will use a lot of memory. If you don't need all 100 of them on one layout, it would be better to use separate objects.

  • Yes all are buttons.ya i thinks i just use 100 frames thanks :)

  • performance wise I don't think it will make a difference either way - you have to decide which way is better for you to manage. if you do keep them as separate sprites, then put them in a family because you don't want to have to issue 100 tweens! your code should be no longer than Kyatric's.

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