Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Changing sprites by scripting  (Read 2408 times)

0 Members and 1 Guest are viewing this topic.

Henke

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 6
    • View Profile
Changing sprites by scripting
« on: August 19, 2013, 04:29:57 PM »

What's the best solution for having the player dropping an object each time they pick up a new one?

I'm guessing having a blank entity for each object in each scene and having global variables determining which sprite should be assigned to which entity seems the best way to do it. I'm having trouble with the scripting though (I'm new at this, the solution might be a cakewalk). Any ideas?
Logged

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: Changing sprites by scripting
« Reply #1 on: August 20, 2013, 07:11:18 AM »

It depends how many objects and how many scenes i guess :)

Another way would be creating entities via script, so you can create them dynamically. But you have to recreate them each time you load the scene storing the name of the object and the X and Y coordinates on the scene's global variable.
Keep in mind that loading the sprite for the objects can take some time (it depends on the size of the image and if it's animated) and the game can froze while loading.

So i think that if there are few objects and few scenes, and you know exactly where you can take/drop some objects and where not, using an entity already created would be ok.
Otherwise if you have a lot of objects/scenes it would probably better to create them via script (using methods and functions). It could be a bit tricky at the beginning but after you have the code you can use it for any object/scene, don't matter how many they are.
Logged
 

Page created in 0.032 seconds with 19 queries.