How do I set cursor from sprite in a better way

0 favourites
  • 10 posts
From the Asset Store
Mouse cursor is something that the player controls and sees all the time, that's why it is so important to make it cool!
  • Someone knows how to do this without puting all the objects in the condition?cause its not a problem now, but will be when I have hundreds or thousands of colectable objects. And, in my understanding, it will decrease the performance a lot of the game. Someone knows if it's even true or a solution for it?

    Thank you

  • That depends,

    If you have at least the personal version, use families for everything

    Either way, It looks like some objects are cloned, is there a difference between trees 1 and 2?

  • Your not actually using 1 Sprite Object for each different Game Object?

    no no no

    Use 1 Sprite Object and then use the animation frames to distinguish the image. Also add a variable to the Object called say TYPE of text. Then write down the TYPE ie TREE, ROCK, WELL, WHEAT..... um no you don't need to use CAPITALS, I only used them to identify key words.

    So you can nicly sum up all your actions to

    Cursor over Collectables

    -- set CursorSprite.animation(Collectable.type)

    -- mouse.setCurstorFromSprite( CursorSprite )

    And then that's it.

    This also makes your life easier than just EventCode too. In fact when you a tree image in your Collectables Sprite Object under say the animation name of "TREE". Then you just need to set the default animation to TREE for that object. Then you can copy/paste the tree where ever you want.

    Then you take that tree and add a rock image to the animation name of ROCK. Clever huh . then set the default animation to ROCK. THen you can copy and paste your rock ALL over the place.

    And best of all you EventCode will work the same for your mouse cursor change.

  • Your not actually using 1 Sprite Object for each different Game Object?

    no no no

    Use 1 Sprite Object and then use the animation frames to distinguish the image. Also add a variable to the Object called say TYPE of text. Then write down the TYPE ie TREE, ROCK, WELL, WHEAT..... um no you don't need to use CAPITALS, I only used them to identify key words.

    So you can nicly sum up all your actions to

    Cursor over Collectables

    -- set CursorSprite.animation(Collectable.type)

    -- mouse.setCurstorFromSprite( CursorSprite )

    And then that's it.

    This also makes your life easier than just EventCode too. In fact when you a tree image in your Collectables Sprite Object under say the animation name of "TREE". Then you just need to set the default animation to TREE for that object. Then you can copy/paste the tree where ever you want.

    Then you take that tree and add a rock image to the animation name of ROCK. Clever huh . then set the default animation to ROCK. THen you can copy and paste your rock ALL over the place.

    And best of all you EventCode will work the same for your mouse cursor change.

    I didn't understand really well for the both tips. In this way, can I set different values, even using just one sprite with a bunch of diferrent animations (Tree, Rocks, etc)? Cause I need to control the loot of every single rock, tree, etc. For example: I see two rocks in the screen and then I collect all the loot of one rock, then I'll to another rock to collect more. Then, after 5 min(it start counting right after ends its loot), reset the loot again so I can collect more.

    Thats how I've being doing about the collectable objects.

    About the cursor, I didn't understand at all. If you print an example event I will appreciate a lot.

  • That depends,

    If you have at least the personal version, use families for everything

    Either way, It looks like some objects are cloned, is there a difference between trees 1 and 2?

    Yes, they must have different instance variables to store their loot. So I can collect wood from tree 1 until it ends, then I collect more wood from tree2. The object didnt get destroied. Instead of it, I restore the loot after a couple minutes.

  • > That depends,

    > If you have at least the personal version, use families for everything

    > Either way, It looks like some objects are cloned, is there a difference between trees 1 and 2?

    >

    Yes, they must have different instance variables to store their loot. So I can collect wood from tree 1 until it ends, then I collect more wood from tree2. The object didnt get destroied. Instead of it, I restore the loot after a couple minutes.

    From the sound of it,, the only difference between the two trees is how much wood they have. You can easily use the same object for both of them, instance variables are calculated and stored on a per instance basis. You could have any number of "tree1"s and set them all differently, and if you take loot from one "tree1" the other won't lose it's loot; as long as you make a distinction in your events, construct will pick out the right one. If you need to restore them back to a certain number in a few minutes, just make a second value to set it back to.

  • >

    > > That depends,

    > > If you have at least the personal version, use families for everything

    > > Either way, It looks like some objects are cloned, is there a difference between trees 1 and 2?

    > >

    >

    > Yes, they must have different instance variables to store their loot. So I can collect wood from tree 1 until it ends, then I collect more wood from tree2. The object didnt get destroied. Instead of it, I restore the loot after a couple minutes.

    >

    From the sound of it,, the only difference between the two trees is how much wood they have. You can easily use the same object for both of them, instance variables are calculated and stored on a per instance basis. You could have any number of "tree1"s and set them all differently, and if you take loot from one "tree1" the other won't lose it's loot; as long as you make a distinction in your events, construct will pick out the right one. If you need to restore them back to a certain number in a few minutes, just make a second value to set it back to.

    See the pic I posted before? There is showing how I did and how I restore the instance variable(the loot). But using the same object like you are saying, I really don't know how to do this. The way I did, using the same tree object, I collect both but to restore that really gets me. How do I say to construct that it's needed to restore the loot of these 2 trees, which is the same object and respecting the delay of each one, otherwise they would be restored all in the same time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Make another variable holding the timer. If wood=0. Subtract dt from timer. If timer less than or equal to 0. Set the timer and Wood back to their original values (To specify a restock time and amount per instance, just create just create a value for each, and set each to those values. Otherwise, just put a number to set them back to). There's also a timer behavior you can use, but it can be a bit tricky to work with.

  • Make another variable holding the timer. If wood=0. Subtract dt from timer. If timer less than or equal to 0. Set the timer and Wood back to their original values (To specify a restock time and amount per instance, just create just create a value for each, and set each to those values. Otherwise, just put a number to set them back to). There's also a timer behavior you can use, but it can be a bit tricky to work with.

    I think I got it. I'll try it as soon as possible..

    Thank you, man!

  • Thank you! I did like this and it works, apparently. I put 2 trees, which is the same object, and both have it's loot restored respecting the cooldown.

    I don't know if it was exactly like you were saying but what's your opinion about the events?

    Thank you again buddy. I really appreciate the help.

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