How to create an object's animation and its shadows by using sprite sheet ?

Hi all,

I want to create a plane’s animation and its shadows
by using 2 sprite sheets. But i encountered an issue
of low performance when combining two sprites together
– one is a group of plane’s pictures, the other is its
shadow pictures.
Could you please give me some advices about how to deal
with this problem ?
Thank you in advance.
Eric [import]uid: 79707 topic_id: 21915 reply_id: 321915[/import]

What do you mean “combining”? Do you mean a multiset or simply using two sheets at once for two different independent sprites?

Sorry, just trying to picture what you’re doing so I can (hopefully) offer some advice here.

Peach :slight_smile: [import]uid: 52491 topic_id: 21915 reply_id: 87253[/import]

Thank you for your kindly reply.

There are two different sprite sheets.
Combining two sprites means a shadow’s sprite follows a plane’s sprite in background
by updating plane’s location accordingly. Maybe this method is wrong.

I look forward to your good advice and correction.
The following is the procedure code.

– Initial plane and its shadow sprite sheets
local PlaneObjectShadow = sprite.newSprite( shadowSet )
local PlaneObject = sprite.newSprite( spriteSet )
PlaneObjectShadow:prepare(PlaneShadowName)
PlaneObject:prepare(PlaneName)

– Initial Velocity
PlaneObject:setLinearVelocity( Vx,Vy )
PlaneObjectShadow:setLinearVelocity( Vx,Vy )

– Update location
PlaneObjectShadow.x = PlaneObject.x + 10
PlaneObjectShadow.y = PlaneObject.y + 10

– Start two animations at once may cause low performance
PlaneObject:play()
PlaneObjectShadow:play() [import]uid: 79707 topic_id: 21915 reply_id: 87289[/import]

You could make them a group (eg, planeGroup) and move the group - that’s neither here nor there, though.

Where are you seeing the low performance? Simulator, device or both?

The first thing I would check in texture memory usage - can you let me know where that’s at right now, please?

(Can use the below function);

[lua]local function monitorMem(event)
collectgarbage(“collect”)

print( “\nMemUsage: " … (collectgarbage(“count”)/1000) … " MB”)
print("Texture Usage " … system.getInfo( “textureMemoryUsed” ) / 1000000)

return true
end

Runtime:addEventListener(“enterFrame”, monitorMem)[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 21915 reply_id: 87422[/import]

Hi Peach,

I have check the texture memory. That is no problem.
Instead, i found the cause of this issue is a for-loop, which constantly searches and updates a warning sprite by frame rate.

I will try to solve this problem.
Thanks for your support.

BR
Eric

[import]uid: 79707 topic_id: 21915 reply_id: 90060[/import]