Hello fellow developers.
I have some strange problem and stuck with it.
All code works but when the sprite is out of view and I tried to show it (set tint/alpha to 1) and move to screen I see only part of it.
Game object is composite: body/outfit/emotions
I tried all I can, but this does not help (fight with this bug for weeks)
That’s is great if you can help me with this pesky blocker bug. I cannot continue development until the scene is fixed.
Here is code for sprites manipulation:
elseif( message_id == hash("show_animated_from_left"))then
print('slavya_manager:show_animated_from_left')
print('emotion: '..emotion..' outfit: '..outfit)
enable()
set_slavya_alpha( 1.0 )
set_new_emotion_and_outfit()
set_position( 0, CENTER_Y )
animate_pos( CENTER_X, 0, 1.0)
function enable()
msg.post("#emotion", "enable" )
msg.post("#body", "enable")
msg.post("#outfit", "enable")
msg.post(blink_sprite, "enable")
end
function set_slavya_alpha( to_a )
set_slavya_tint( old_r, old_g, old_b, to_a )
end
local old_r = 1
local old_g = 1
local old_b = 1
local old_a = 1
function set_slavya_tint( r, g, b, a )
if( a == nil )then a = 1 end
old_r = r
old_g = g
old_b = b
old_a = a
sprite.set_constant("#emotion", "tint", vmath.vector4(r, g, b, a))
sprite.set_constant("#body", "tint", vmath.vector4(r, g, b, a))
sprite.set_constant("#outfit", "tint", vmath.vector4(r, g, b, a))
end
function set_new_emotion_and_outfit()
set_emotion( emotion, outfit )
end
function set_emotion( emotion, outfit )
print("slavya_manager.script: set_emotion (emotion: " .. tostring(emotion) .. ", outfit: ".. tostring(outfit) .. ")")
if(outfit == nil)then
print("slavya_manager.script: set_emotion outfit is nil")
outfit = OUTFIT_PIONEER
end
local pose = POSES[emotion]
local outfit = pose.outfit[outfit]
print('Pose: body>'..pose.body..' emotion>'..pose.emotion..' outfit>'..outfit)
msg.post("#emotion", "play_animation", {id=hash(pose.emotion)})
msg.post("#body", "play_animation", {id=hash(pose.body)})
msg.post("#outfit", "play_animation", {id=hash(outfit)})
if( blink_sprite ~= "" )then
msg.post( blink_sprite, "disable" )
end
blink_sprite = pose.blink.sprite
blink_animation = pose.blink.animation
print( "emotion " .. emotion .. " outfit " .. outfit .. " blink animation " .. blink_animation )
if( blink_sprite ~= "" )then
msg.post( blink_sprite, "enable")
else
msg.post(blink_sprite, "disable")
end
end
function set_position( to_x, to_y )
local pos = vmath.vector3()
pos.x = to_x
pos.y = to_y
go.set_position( pos )
end
function animate_pos( to_x, to_y, duration )
if( to_x ~= 0 )then
go.animate(".", "position.x", go.PLAYBACK_ONCE_FORWARD, to_x, go.EASING_LINEAR, duration )
end
if( to_y ~= 0 )then
go.animate(".", "position.y", go.PLAYBACK_ONCE_FORWARD, to_y, go.EASING_LINEAR, duration )
end
end