Moving object

Hey. I ran into a problem. How to make the object move in the direction where the joystick is directed. I am using vjoy.lua

Hi @dimidrol3031

Please show us some of your code and use the <> buttons in the menu bar to format the code.  Also, please include a link to the vjoy.lua documentation or the file itself.

<–Добавление карты
gridmap = require “gridmap”
mapData = require “map1”
map = gridmap:createMap(mapData)
local group = display.newGroup()
group:insert(1, map)

–Перемещение карты по осям
local function mapOffset(x, y)
for i = 1, #mapData.layers do
if mapData.layers[i].type == “tilelayer” then
mapData.layers[i].x = mapData.layers[i].x-x
mapData.layers[i].y = mapData.layers[i].y-y
end
end
group:insert(1, map)
map:removeSelf()
map = gridmap:createMap(mapData)
group:insert(1, map)
end
mapOffset(-1, 2)

– Добавление джойстика
local vjoy = require( “com.ponywolf.vjoy” )
local stick = vjoy.newStick()
–Его координаты
stick.y = 560, display.contentHeight - 200
stick.x = 15, display.contentHeight - 0
>

Map isometric. I want to make the card move in the opposite direction from the vjoy direction. Thus make the movement of the character, which will be in the center.

What information are you retrieving from the joystick?  It looks like it dispatches information to the global Runtime object so I imagine you would retrieve this information from axisEvent (global value).

[lua]

axisEvent = {name = “axis”, axis = { number = startAxis+1 }, normalizedValue = instance.axisY }

Runtime:dispatchEvent(axisEvent)

[/lua]

Sorry, but I’m just getting started with corona. I hope my question doesn’t seem silly to you. How to do it?

Hi @dimidrol3031

Please show us some of your code and use the <> buttons in the menu bar to format the code.  Also, please include a link to the vjoy.lua documentation or the file itself.

<–Добавление карты
gridmap = require “gridmap”
mapData = require “map1”
map = gridmap:createMap(mapData)
local group = display.newGroup()
group:insert(1, map)

–Перемещение карты по осям
local function mapOffset(x, y)
for i = 1, #mapData.layers do
if mapData.layers[i].type == “tilelayer” then
mapData.layers[i].x = mapData.layers[i].x-x
mapData.layers[i].y = mapData.layers[i].y-y
end
end
group:insert(1, map)
map:removeSelf()
map = gridmap:createMap(mapData)
group:insert(1, map)
end
mapOffset(-1, 2)

– Добавление джойстика
local vjoy = require( “com.ponywolf.vjoy” )
local stick = vjoy.newStick()
–Его координаты
stick.y = 560, display.contentHeight - 200
stick.x = 15, display.contentHeight - 0
>

Map isometric. I want to make the card move in the opposite direction from the vjoy direction. Thus make the movement of the character, which will be in the center.

What information are you retrieving from the joystick?  It looks like it dispatches information to the global Runtime object so I imagine you would retrieve this information from axisEvent (global value).

[lua]

axisEvent = {name = “axis”, axis = { number = startAxis+1 }, normalizedValue = instance.axisY }

Runtime:dispatchEvent(axisEvent)

[/lua]

Sorry, but I’m just getting started with corona. I hope my question doesn’t seem silly to you. How to do it?