Is there a simple way to use HardonCollider+hump.camera to effectively pan the view on a top down shooter?
I've been trying for ages to get it to work, but I can't get the HardonCollider objects to stay at the place where they belong.
Also, is there anything like shape:moveTo() for the hump.camera class? Moving the cam using moveTo would be easier than move in some cases.
HardonCollider and hump.camera?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: HardonCollider and hump.camera?
I don't quite understand what you mean. The camera does not affect the position of anything in the game world, just where it is drawn. Are you sure you draw the objects between a cam:attach()/cam:detach() pair? Could you provide some example code (or even better a .love)?MiniDemonic wrote:I've been trying for ages to get it to work, but I can't get the HardonCollider objects to stay at the place where they belong.
Yes:MiniDemonic wrote:Also, is there anything like shape:moveTo() for the hump.camera class? Moving the cam using moveTo would be easier than move in some cases.
hump.camera documentation wrote:To set the position, use camera.pos = some_vector or camera.pos.x, camera.pos.y = new_x, new_y.
-
- Prole
- Posts: 28
- Joined: Tue Mar 20, 2012 10:39 am
Re: HardonCollider and hump.camera?
The camera is working fine for all the drawn objects, but I want the hardoncollider objects to keep their position relative to where the camera is moving, I know that the camera doesn't affect the objects which is why I need help with a function to move the objects to their correct positions.
Re: HardonCollider and hump.camera?
I'm not sure why you'd want to move the collision shapes without their sprites (unless I've misunderstood what you want)
I've attached a really basic .love of 3rd person top down game I just started working on. I've reverted back to 0.7.2 since the 0.8.0 version wasn't working. I use hardoncollider and hump.camera for my collision and viewport, you can read the code to see how. (you can also delete the black blocks after pressing 0 or replace them after pressing 1)
Hope it helps.
I've attached a really basic .love of 3rd person top down game I just started working on. I've reverted back to 0.7.2 since the 0.8.0 version wasn't working. I use hardoncollider and hump.camera for my collision and viewport, you can read the code to see how. (you can also delete the black blocks after pressing 0 or replace them after pressing 1)
Hope it helps.
- Attachments
-
- 3rdperson.love
- (54.09 KiB) Downloaded 180 times
It was the best of times, it was the worst of times . . .
-
- Prole
- Posts: 28
- Joined: Tue Mar 20, 2012 10:39 am
Re: HardonCollider and hump.camera?
Well I am using AdvTiledLoader to draw the tilemaps, the sprites and the collision objects are separated, which means that I need to move the collision objects with the tilemap, unless there is a way to draw the tiles on the collision objects using AdvTileLoader.
Re: HardonCollider and hump.camera?
You can get the camera position using cam.pos (as already mentioned). I've never done anything with the advanced tiled loader, but from the example it should work about like this:MiniDemonic wrote:I want the hardoncollider objects to keep their position relative to where the camera is moving,
Code: Select all
global.tx = cam.pos.x
global.ty = cam.pos.y
global.scale = cam.zoom
Code: Select all
local x,y = cam:worldCoords(0,0):unpack()
local w,h = love.graphics.getWidth()/cam.zoom, love.graphics.getHeight()/cam.zoom
map:setDrawRange(x,y,w,h)
cam:attach()
map:draw()
cam:detach()
-
- Prole
- Posts: 28
- Joined: Tue Mar 20, 2012 10:39 am
Re: HardonCollider and hump.camera?
Sorry for late response, I've been busy and haven't been able to check the forum.
I appreciate your efforts vrld, but that didn't achieve what I was looking for, I abandoned the scrolling map idea and is going to stick with a normal "switch map at screen edge" kind of deal. (will probably use entities in the game instead of checking for the screen edge)
If someone does however know how to do it then I appreciate the help.
Although I'm starting to think that it is impossible to do scrolling maps with AdvTiledLoader+HardonCollider.
I appreciate your efforts vrld, but that didn't achieve what I was looking for, I abandoned the scrolling map idea and is going to stick with a normal "switch map at screen edge" kind of deal. (will probably use entities in the game instead of checking for the screen edge)
If someone does however know how to do it then I appreciate the help.
Although I'm starting to think that it is impossible to do scrolling maps with AdvTiledLoader+HardonCollider.
Re: HardonCollider and hump.camera?
It's possible. More or less using the way I showed you.MiniDemonic wrote:Although I'm starting to think that it is impossible to do scrolling maps with AdvTiledLoader+HardonCollider.
-
- Prole
- Posts: 28
- Joined: Tue Mar 20, 2012 10:39 am
Re: HardonCollider and hump.camera?
Thanks once again, I checked out the link you gave me and I found out how to accomplish what I was looking for.
It is now working as I expected You will see my game soon enough, just need to remove a few bugs and add a couple of stuff.
The game is going to be a singleplayer zombie shooter rpg, might try to make it online in the future but need to get better at love2d first.
The game will cycle between night and day every 10 minutes, and on the day you are supposed to go around and search for food/ammo, on the night you need to survive the zombie horde.
Upon gaining enough exp you will level up and be able to choose from a set of stats, i.e Ammo Capacity, Health, Speed, Reload Speed, Stamina etc etc.
It is now working as I expected You will see my game soon enough, just need to remove a few bugs and add a couple of stuff.
The game is going to be a singleplayer zombie shooter rpg, might try to make it online in the future but need to get better at love2d first.
The game will cycle between night and day every 10 minutes, and on the day you are supposed to go around and search for food/ammo, on the night you need to survive the zombie horde.
Upon gaining enough exp you will level up and be able to choose from a set of stats, i.e Ammo Capacity, Health, Speed, Reload Speed, Stamina etc etc.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 81 guests