It looks like you're new here. If you want to get involved, click one of these buttons!
local properties = {}; local parentSprite = Sprite:new() parentSprite:setPosition(512, 400) parentSprite:set("anchorX", 0.5) parentSprite:set("anchorY", 0.5) -- parentSprite:setWidth(1024) -- parentSprite:setHeight(800) local parentAnim = {} parentAnim.x = 1177 parentAnim.y = 400 parentAnim.anchorY = 0.5 parentAnim.anchorX = 0.5 local down = Bitmap.new(Texture.new("star.png")) local up = Bitmap.new(Texture.new("star.png")) up:setPosition(197, 205) up:setAnchorPoint(0.5, 0.5) down:setPosition(197, 95) down:setAnchorPoint(0.5, 0.5) local upAnim = {} upAnim.x = 197 upAnim.y = 95 upAnim.anchorX = 0.5 upAnim.anchorY = 0.5 local downAnim = {} downAnim.x = 197 downAnim.y = 205 downAnim.anchorX = 0.5 downAnim.anchorY = 0.5 local rotor = Bitmap.new(Texture.new("star.png")) rotor:setPosition(286, 225) rotor:setAnchorPoint(0.5, 0.5) rotor:setRotation(0) local rotorAnim = {} rotorAnim.x = 286 rotorAnim.y = 225 rotorAnim.anchorX = 0.5 rotorAnim.anchorY = 0.5 rotorAnim.rotation = 360 local properties = {}; properties.delay = 0; properties.dispatchEvents = true stage:addChild(parentSprite) parentSprite:addChild(up) parentSprite:addChild(down) parentSprite:addChild(rotor) stage:addChild(parentSprite) local upTween = GTween.new(up, 5, upAnim, properties) local downTween = GTween.new(down, 5, downAnim, properties) local rotorTween = GTween.new(rotor, 1, rotorAnim, properties) local parenttweener = GTween.new(parentSprite, 5, parentAnim, properties) |
Comments
As anchorpoint of the parent is calculated based on starting dimensions of the parent, the changes in its dimensions make them jump.
If you disable setting anchorpoint to parent it should work as expected.
So what you can do, is not setting an anchor point to parent, but rather set negative position values to some child members, thus making it behave like anchored to some specific position
something like
local dummy1 = Sprite:new()
dummy1:setPosition("left", "top")
local dummy2 = Sprite:new()
dummy2:setPosition("right", "bottom")
Is there no better way to set the bounds to parent sprite ?
Is there a memory impact to setting the sprite to screen size ? ( assuming not! )
BTW- The jerkiness does go away as expected !
2) No there is no better way
3) No I don't think there will be much of an impact, as Sprite is only a holder and does not impact rendering
Likes: uncleking