私はこのコードを持っています。この例では、Graphic:setAnchorPoint と Graphic:setRotation で「Graphic」を「self」に置き換えると、画像は画面に表示されますが、回転しません。理由は何ですか?
私は Gideros を初めて使用し、クラスを作成する際に行う必要がある変更を完全には理解していません。短い簡単な説明が本当に必要ですか?
私はGiderosでLuaを使用しています
WatchHands= Core.class(Sprite)
W, H = application:getDeviceWidth(), application:getDeviceHeight()
H, W = W, H
ori = Application.LANDSCAPE_LEFT
application:setOrientation(ori)
function WatchHands:init(Image, posx, posy)
posx = posx or 0
posy = posy or 0
Graphic = Bitmap.new(Texture.new(Image))
Graphic: setAnchorPoint(0.2257, 0.5)
self:addChild(Graphic)
self: setPosition( posx, posy)
self.width = self: getWidth()
self.height = self: getHeight()
self: setScale(0.5, 1)
Graphic:setRotation(math.random( 1,360))
self:addEventListener(Event.ADDED_TO_STAGE, self.onAddedToStage, self)
return self
end
function WatchHands: playsound(sound)
local channel = sound:play()
return channel
end
function WatchHands: onAddedToStage()
self:addEventListener(Event.ENTER_FRAME,
function()
self:setRotation( Graphic:getRotation() + 5)
Timer.delayedCall(math.random(30000, 60000),
function()
self:setRotation( self:getRotation() + math.random(6,10) )
end)
end)
end
sechand = WatchHands.new("secondshand.png", W/2, H/2)
minhand = WatchHands.new("minutehand.png", W/2, H/2)
stage: addChild(sechand)
stage: addChild(minhand)