Jump to content
Felkami

How do I display an image on the UI?

Recommended Posts

I've been trying to figure out how to display spiffo4.png on the hud, and I just can't figure it out. Here's the code I've been using for testing?

 

require('ISUI/ISPanel');
require('ISUI/ISImage');
require('ISUI/ISCollapsableWindow');

UIImagePanel = {};

function UIImagePanel.new(x, y, width, height, texture)
    title = title or 'test'
    text  = text or 'Bacon ipsum dolor amet strip steak drumstick shankle jerky frankfurter short loin sausage. Short loin hamburger landjaeger turducken. Pork belly bresaola pork drumstick picanha. Rump capicola pork chop ball tip pork loin.'

    local self = {};
    self.tut = ISImage:new(x, y, width, height, texture); --(x, y, width, height, texture)
    self.tut:initialise();
    self.tut:setAnchorBottom(true);
    self.tut:setAnchorRight(true);
    self.moreinfo = self.tut:wrapInCollapsableWindow();
    self.moreinfo:setX((getCore():getScreenWidth() * 0.5) - (self.tut.width * 0.5));
    self.moreinfo:setY((getCore():getScreenHeight() * 0.5) - (self.tut.height * 0.5));
    --self.moreinfo:setTitle(title);

    self.moreinfo:addToUIManager();
    self.tut:setWidth(self.moreinfo:getWidth());
    self.tut:setHeight(self.moreinfo:getHeight() - 16);
    self.tut:setY(16);
    self.tut.autosetheight = false;
    --self.tut.clip = true;
    --self.tut:addScrollBars();

    --self.tut.textDirty = true;
    --self.tut.text = text;
    --self.tut:paginate();
    return self;
end

 

and then called with:

ISImage:new(70, 70, 15, 15, "spiffo4.png");

Share this post


Link to post
Share on other sites
Posted (edited)

Solved!

 

sprite = imageFactory(70, 70, 15, 15, Texture.getSharedTexture("media/ui/spiffo4.png") );


function imageFactory(x, y, width, height, texture)
    local self = {};
    
    --self.image = ISMovImage:new(x, y, width, height, texture);
    self.image = ISMovImage:new((getCore():getScreenWidth() * 0.5) - (width * 0.5), (getCore():getScreenHeight() * 0.5) - (height * 0.5), width, height, texture);
    self.image:initialise();
    self.image:setAnchorBottom(true);
    self.image:setAnchorRight(true);
    --self.wrapper = self.image:wrapInCollapsableWindow();
    --self.wrapper:setX((getCore():getScreenWidth() * 0.5) - (self.image.width * 0.5));
    --self.wrapper:setY((getCore():getScreenHeight() * 0.5) - (self.image.height * 0.5));

    --self.wrapper:addToUIManager();
    --self.image:setWidth(self.wrapper:getWidth());
    --self.image:setHeight(self.wrapper:getHeight() - 16);
    --self.image:setY(16);
    --self.image.autosetheight = false;
    
    self.image:addToUIManager();

    return self;
end
   

 

Edited by Felkami

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...