Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Poll

Cant reach inventory's sprite object:(

inventory sprite problem
- 0 (0%)
cant reach inventory obejct
- 0 (0%)

Total Members Voted: 0


Author Topic: Cant reach inventory's sprite object:(  (Read 6792 times)

0 Members and 2 Guests are viewing this topic.

BLUE ARC

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 3
  • www.akcaykaraazmak.com
    • View Profile
    • BLUE ARC STUDIOS
Cant reach inventory's sprite object:(
« on: June 12, 2010, 12:56:20 PM »

Hello :)

Our inventory'a image is an animated sprite. But the problem is I cant reach that sprite from code:s
Where I can assign a name to that sprite that I used for inventory image? So I can reach that sprite from codes.

global inv = Scene.GetNode("inventory"); // the file name of the sprite image, inventory.sprite.
inv.Active = true;
global inventory_frame = inv.GetSpriteObject();

// from the code below, I should get and reach the filename,... and the other attributes of the sprite but I cant:(
Game.Msg(inventory_frame.Filename);   // return value is null :(
Game.Msg(inventory_frame.CurrentFrame);  // return value is null :(


We will be very happy is someone could guide us. Cheers :)
Logged

Akatosh

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 14
  • Discomfort generates evolution.
    • View Profile
Re: Cant reach inventory's sprite object:(
« Reply #1 on: June 12, 2010, 03:13:08 PM »

Hello,

Well there are simple ways to change your inventory's background image. Just use the standard window editor. Click on inventory.def under the interface folder and in the inventory's background just choose your .sprite image.

If you, somehow, want to do it using code, try doing something like:

var inv = Game.GetInventoryWindow();
inv.SetImage("interface\animatedSprite.sprite");

I hope this was the answer you were looking for.

BLUE ARC

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 3
  • www.akcaykaraazmak.com
    • View Profile
    • BLUE ARC STUDIOS
Re: Cant reach inventory's sprite object:(
« Reply #2 on: June 12, 2010, 03:32:20 PM »

Thank you very much for your response mate.

var inv = Game.GetInventoryWindow();
inv.SetImage("interface\animatedSprite.sprite");

I use your code and assigne the animated sprite with SetImage but then how hen how could I reach
that animatedSprite.sprite's properties? For example I want to stop the sprite animation on its last frame or do some other actions on that sprite but
how I can make a call to it?

And where I can give a name for that sprite so I can reach it or call it from code?. The "name" property doesnt work on sprite editor.

Thank you:)



Logged

Akatosh

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 14
  • Discomfort generates evolution.
    • View Profile
Re: Cant reach inventory's sprite object:(
« Reply #3 on: June 12, 2010, 03:54:04 PM »


I use your code and assigne the animated sprite with SetImage but then how hen how could I reach
that animatedSprite.sprite's properties? For example I want to stop the sprite animation on its last frame or do some other actions on that sprite but
how I can make a call to it?

And where I can give a name for that sprite so I can reach it or call it from code?. The "name" property doesnt work on sprite editor.

Thank you:)

Well, you can always take the loop off in the Sprite Editor or you access it by doing something like:

// Assuming inv was already declared up.
var backgroundImage = inv.GetImage(); // backgroundImage has a reference for a sprite type variable.
backgroundImage.Pause();

For more Sprite functions, you can always check http://docs.dead-code.org/wme/generated/scripting_ref_sprite.html

Hope this helps :)


« Last Edit: June 12, 2010, 03:56:24 PM by Akatosh »
Logged

BLUE ARC

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 3
  • www.akcaykaraazmak.com
    • View Profile
    • BLUE ARC STUDIOS
Re: Cant reach inventory's sprite object:(
« Reply #4 on: June 12, 2010, 03:58:46 PM »

Thank you very much mate, I ll try to do your advice :)
Logged

robot

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 38
    • View Profile
Re: Cant reach inventory's sprite object:(
« Reply #5 on: June 12, 2010, 04:07:53 PM »

hi! just wanted to start a new topic then i saw this one... may it fits in here:

does the inventory have a owning object?
i ask because my inventory is an animated sprite. now i want to trigger an event and i don't know where i have to catch it
i tried in the game- , scene-  and inventory script -  ::thumbdown
and by the way: when i add a script to the inventory box in the inventory.def file, it doesn't save. perhaps its not meant to add script here?

thanks
Logged

Andrej (Blue Arc)

  • Occasional poster
  • **
  • Karma: 1
  • Offline Offline
  • Gender: Male
  • Posts: 73
    • View Profile
Re: Cant reach inventory's sprite object:(
« Reply #6 on: June 12, 2010, 07:42:48 PM »

does the inventory have a owning object?
i ask because my inventory is an animated sprite. now i want to trigger an event and i don't know where i have to catch it
i tried in the game- , scene-  and inventory script -  ::thumbdown
and by the way: when i add a script to the inventory box in the inventory.def file, it doesn't save. perhaps its not meant to add script here?

Hi,

if you added script in WindowEdit to your inventory you should click File->Save. It works fine for me :)
if you want to trigger some event to any frame in your inventory animation you have to add script for your sprite representing inventory panel. There is event array in SpriteEdit there.

Event - individual animation frames can trigger a script event in their owning object; it's useful when you need to synchronize certain script action with an animation (for example playing footstep sounds)

For example your sprite object contains from 20 frame. If 12 frame is currently playing and you want to add some event write your event name to event array. Now write to your script attached to sprite object this code:

on "MyEvent"
{
  DoSomething();
}
Logged

robot

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 38
    • View Profile
Re: Cant reach inventory's sprite object:(
« Reply #7 on: June 12, 2010, 08:42:51 PM »

hmmm, i'm really confused


this is my animated sprite:

Code: [Select]
; generated by SpriteEdit

; $EDITOR_PROJECT_ROOT_DIR$ ..\..\..\

SPRITE {
  NAME="inventory"
  LOOPING=TRUE
  CONTINUOUS=FALSE
  PRECISE=TRUE
  SCRIPT="interface\inventory\invsprite.script"
  FRAME {
    DELAY = 60
    KEYFRAME=FALSE
    IMAGE = "interface\inventory\inventory1.png"
  }

  FRAME {
    DELAY = 60
    KEYFRAME=FALSE
    IMAGE = "interface\inventory\inventory2.png"
  }

  FRAME {
    DELAY = 60
    KEYFRAME=FALSE
    IMAGE = "interface\inventory\inventory3.png"
  }

  FRAME {
    DELAY = 60
    KEYFRAME=FALSE
    IMAGE = "interface\inventory\inventory4.png"
  }

  FRAME {
    DELAY = 60
    KEYFRAME=FALSE
    IMAGE = "interface\inventory\inventory5.png"
    EDITOR_SELECTED=TRUE
    APPLY_EVENT="gotoRandom"
  }

}

in the script attached to it i have following code:

Code: [Select]
on "gotoRandom"
{
  Game.Msg("dsf");
}

but it doesn't trigger.  ??? ???
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Cant reach inventory's sprite object:(
« Reply #8 on: June 13, 2010, 01:53:50 PM »

The events are not triggered in the sprite itself, but in the object, that uses the sprite. For example, if you have a walking animation, and add footstep events to some frames, and the sprite is assigned to some actor, you'll handle the events in actor's script.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

robot

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 38
    • View Profile
Re: Cant reach inventory's sprite object:(
« Reply #9 on: June 14, 2010, 01:09:16 PM »

ok i see so in that case i have to implement the event in the script attached to the inventory.def right?
i tried so, but it didn't trigger so i ask what i've done wrong?

here is the code from the inventory.def:

Code: [Select]
; generated by WindowEdit

; $EDITOR_PROJECT_ROOT_DIR$ ..\..\..\

INVENTORY_BOX
{
  NAME="<unnamed>"
  CAPTION=""
  AREA { 55, 77, 545, 827 }
  EXCLUSIVE=TRUE
  HIDE_SELECTED=TRUE
  ALWAYS_VISIBLE=FALSE
  SPACING=30
  ITEM_WIDTH=100
  ITEM_HEIGHT=100
  SCROLL_BY=1
 
  WINDOW
  {
    NAME="<unnamed>"
    CAPTION=""
   
    IMAGE="interface\inventory\inventory.sprite"
   
    TITLE=""
    TITLE_ALIGN="left"
   
    X=80
    Y=15
    WIDTH=600
    HEIGHT=900
    DISABLED=FALSE
    VISIBLE=TRUE
    PARENT_NOTIFY=FALSE
    TRANSPARENT=FALSE
    PAUSE_MUSIC=TRUE
    MENU=FALSE
    IN_GAME=FALSE
    CLIP_CONTENTS=FALSE
   
    ALPHA_COLOR { 0, 0, 0 }
    ALPHA=0
   
    SCRIPT="interface\inventory\inventory.script"
   
    EDITOR_PROPERTY
    {
      NAME="Selected"
      VALUE="True"
    }

  }
 
  EDITOR_PROPERTY
  {
    NAME="Selected"
    VALUE="False"
  }

}
Logged
 

Page created in 0.041 seconds with 27 queries.