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: How exactly do you load a sprite many times on screen?  (Read 3794 times)

0 Members and 1 Guest are viewing this topic.

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
How exactly do you load a sprite many times on screen?
« on: January 02, 2009, 01:51:50 AM »

Mabey i am to tired or somthing but i am unable to see how to load a sprite onto the screen?

All i want to do is use a script to load a single sprite many times in diffrent places on the screen...

Code: WME Script
  1. on "LeftClick"
  2. {
  3. Game.Msg("test");
  4. var temp = Game.LoadEntity("scenes\Room\button.sprite");
  5. temp.X = 70;
  6. temp.Y = 41;
  7. }

This is the code of the left click event i am using... all it is ment to do is load button.sprite and palce it at 70,41?

Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

sychron

  • Wanderer zwischen den Welten
  • Global Moderator
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 223
  • There is no spoon. The enemy gate is down!
    • View Profile
Re: How exactly do you load a sprite many times on screen?
« Reply #1 on: January 02, 2009, 09:23:14 AM »

At first glance: You may have to activate or show the entity.
Logged
... delete the inner sleep ...

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How exactly do you load a sprite many times on screen?
« Reply #2 on: January 02, 2009, 10:00:08 AM »

Entity is not sprite. Entity is a rather smart scene object and sprite is just one of its properties.
So you either need to load an *entity* from file (see the "Old Guy" in WME demo for reference) or create the entity dynamically in script:

Code: WME Script
  1. var Ent = Scene.CreateEntity();
  2. Ent.SetSprite("scenes\Room\button.sprite");
  3. Ent.X = 70;
  4. Ent.Y = 41;
  5.  

Note that I'm using Scene.CreateEntity(), not Game.CreateEntity(). That will ensure that the entity is automatically destroyed after the player leaves the scene.

Also, entities are part of the scene. If you want to create user interface (judging by the name "button"), perhaps a window would be better suited. You can dynamically create buttons within a window in a similar fashion.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.077 seconds with 21 queries.