Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Composite images syntax question
Started by sharp100 Feb 06 2017 08:10 AM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

sharp100

[GLOBAL: userInfoPane.html]
sharp100
  • Enthusiast

  • 83 posts
  • Corona SDK

I need to load images into a composite paint table in an unconventional way.

-- usually I do it like this
 
local compositePaint = {
    type="composite",
    paint1={ type="image", filename="image1.png" },
    paint2={ type="image", filename="image2.png" }
}
 
-- but I'd like to do something like this (does not work, I tried it)
 
local sprite1 = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite1")}} )
local sprite2 = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite2")}} )
 
local compositePaint = {
    type="composite",
    paint1={ sprite1 },
    paint2={ sprite2 }
}

 

I would also consider using snapshots or canvases but have no idea if there is an alternate syntax I can use to load sprites, snapshots or canvases into a composite paint table.

 

My last resort would be to save the sprites as PNG's and then load them into the composite paint table as that would defeat the purpose of image sheets and bloat the app.

 

Ideas?

 

Thanks,

Jonathan



[TOPIC: post.html]
#2

StarCrunch

[GLOBAL: userInfoPane.html]
StarCrunch
  • Contributor

  • 570 posts
  • Enterprise

Canvases expose filename and baseDir properties, allowing them to be passed to paints as in your "usually I do it like this" case.



[TOPIC: post.html]
#3

sharp100

[GLOBAL: userInfoPane.html]
sharp100
  • Enthusiast

  • 83 posts
  • Corona SDK

I will try that, thanks!




[topic_controls]
[/topic_controls]