Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
'Rocky Climb' mechanics - how to? — Gideros Forum

'Rocky Climb' mechanics - how to?

Hey guys!
I'm trying to understand basic 'Rocky Climb' mechanics (https://play.google.com/store/apps/details?id=com.estoty.rockyclimb )

* How would you generate whole level? (spawn every next stone in radius maybe 190px of previous stone, after tap check if player is close enough to his nearest stone)
* How to make screen always centered on player? (after few taps player will be offscreen)
* Is there a smarter solution to rotate player? (I'm using two anchors there)

(I've attached my current gproj setup)
local player = Bitmap.new(Texture.new("player.png",true))
local stone = Bitmap.new(Texture.new("stone.png",true));
 
stone:setAnchorPoint(.5,.5); stone:setPosition(200,500); stone:setScale(.5)
player:setPosition(200,500); player:setScale(.5);
 
stage:addChild(stone); stage:addChild(player)
 
local mainAnchor=Pixel.new(0xff0000,1,10,10)--red main anchor
player:addChild(mainAnchor)
 
local secondAnchor=Pixel.new(0x0000ff,1,10,10)--blue secondary anchor
player:addChild(secondAnchor)
secondAnchor:setPosition(-245,-255)
 
player:setAnchorPoint(.85,.85)
player.isClockwise=true
player.rotationDir=1
player.speed=2.5
 
--ON ENTER_FRAME ROTATE PLAYER:
local function onEnterFrameFunc()
	player:setRotation(player:getRotation()+player.rotationDir*player.speed)
end
stage:addEventListener(Event.ENTER_FRAME, onEnterFrameFunc)
 
--ON TAP:
local function onTapFunc(event)
	local x,y=secondAnchor:localToGlobal(secondAnchor:getAnchorPosition())
 
	if player.isClockwise==true then
		player.isClockwise=false
		player:setAnchorPoint(.2,.1)
		secondAnchor:setPosition(245,255)
	else
		player.isClockwise=true
		player:setAnchorPoint(.85,.85)
		secondAnchor:setPosition(-245,-255)
	end
	player.rotationDir=-player.rotationDir
 
	player:setPosition(x,y)
	pulsePlayerScale()
end
stage:addEventListener(Event.MOUSE_DOWN, onTapFunc,self)
 
function pulsePlayerScale()
	local makePlayerSmaller=GTween.new(player, .2, {scaleX=0.4,scaleY=0.4}, {delay = 0, ease = easing.linear, onComplete = function()
		local makePlayerNormal=GTween.new(player, .2, {scaleX=0.5,scaleY=0.5}, {delay = 0, ease = easing.linear})
	end})
end
image
zip
zip
RockyClimb.zip
54K
spawnNextStone.png
482 x 856 - 20K
> Newcomers roadmap: from where to start learning Gideros
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)

Comments

Sign In or Register to comment.