It looks like you're new here. If you want to get involved, click one of these buttons!
local tilemap = TileMapMultiple.new("level1.lua") stage:addChild(tilemap) local qatan2 = math.atan2 local qsin = math.sin local qcos = math.cos local player1 = Bitmap.new(Texture.new("shooterRambo.png")) player1:setAnchorPoint(0.5,0.5) player1:setRotation(0) player1.x = 100 player1.y = 100 player1.speed =1 player1.targetX = 100 player1.targetY = 100 stage:addChild(player1) function onEnterFrame(event) local x = player1:getX() local y = player1:getY() y = y + (qsin(qatan2(player1.targetY - y, player1.targetX - x))*1); x = x + (qcos(qatan2(player1.targetY - y, player1.targetX - x))*1); player1:setX(x) player1:setY(y) --This is what I have tried player1:setRotation(qatan2(player1.targetY - y, player1.targetX - x)) end function onMouseDown(event) player1.targetX = event.x player1.targetY = event.y end stage:addEventListener(Event.MOUSE_DOWN, onMouseDown) stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) |
Comments
You need...
evs
I've tried all sorts of things, and have had various results from the player and map moving to far in
I've tried this:
player1:setX(x)
player1:setY(y)
tilemap:setX(-x)
tilemap:setY(-y)
but it moves the map and player in each direction to far, I understand that I have to not change the players x and y, and keep him in the center of the screen, but I'm unsure of how.
I've also tried this;
player1:setX(application:getContentWidth()*0.5)
player1:setY(application:getContentHeight()*0.5)
tilemap:setX(-x)
tilemap:setY(-y)
but it doesn't really move the man.
any help would be gratefully appreciated, as I'm learning this new tool
Given the way the gideros tilemap stuff works when you set the tilemap to 0,0 it draws the top left corner of the map in the top left corner of the screen and adjusting the x to make it negative will "scroll" the map to the left, this seems a little counter intuitive as your tilemap x coord goes from 0 (extreme left) to -(world_width-screen_width) (extreme right) however it's fairly easy to create a mapping from a "world" coordinate system to a "screen" coordinate system.
It might be easier to post a simple example from your code and let us have a look
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
I'll get searching for some examples.
anway here's my code
http://www.giderosmobile.com/forum/discussion/comment/5546#Comment_5546