Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

display group does not appear
Started by karagozkenan Nov 19 2016 03:51 AM

5 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

karagozkenan

[GLOBAL: userInfoPane.html]
karagozkenan
  • Observer

  • 10 posts
  • Corona SDK

although the touch event is working,the dpad does not show on the screen. have i done somethimg wrong on my code.

thanks for your help

function scene:create( event )
    local sceneGroup = self.view    
    display.setDefault("background", 0.2 )

    physics.start() 
    physics.setGravity(0,90)
    physics.pause() 


    --loading map
    local mapData = require("maps.level"..G.currentLevel)
    local map = tiled.new(mapData,"maps")
    sceneGroup:insert(map)
    map.x,map.y =0,0

    --player nesnesi
    player=require ("player");
    sceneGroup:insert(player)
    local mapPlayer=map:getObjectByName(map.layerGroups["player"],"objPlayer")
    player.x,player.y=mapPlayer.x,mapPlayer.y                      
    
    dpad=require "dpad"
    sceneGroup:insert(dpad)    
    dpad:toFront()--dpad doesnt appear!!!!!!!!!!!
   
    
  --camera system 
    camera = perspective.createView()
        
    camera:add(player, 1)     
    camera:prependLayer()
    
    camera:add(map.layerGroups["sky"],4)
    camera:add(map.layerGroups["landBack"],3)
    camera:add(map.layerGroups["land"],2)       
    camera:setParallax(1, 1, 1, 0.1)
        
    camera:setBounds(display.contentCenterX,map.designedWidth-display.contentCenterX-32,        display.contentCenterY,map.designedHeight-display.contentCenterY)
    camera.damping = 10 
    camera:setFocus(player)
    camera:track()          
      
end


[TOPIC: post.html]
#2

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 430 posts
  • Corona SDK

It looks to me like you've required the dpad module but not done anything else with it.

Normally you would have to call the module to create the object.

Without knowing which dpad module you're using I couldn't say how to initialise it.  Check the documentation that should have come with the module.



[TOPIC: post.html]
#3

karagozkenan

[GLOBAL: userInfoPane.html]
karagozkenan
  • Observer

  • 10 posts
  • Corona SDK

--dpad.lua

local controlGroup = display.newGroup()
local Dpad = display.newImageRect(controlGroup, "assets/images/control.png", 128, 32)
Dpad.x = 80
Dpad.y = display.viewableContentHeight - 40
local jmp=display.newImageRect(controlGroup,"assets/images/jump.png",64,64)
jmp.x = display.viewableContentWidth- 50
jmp.y = display.viewableContentHeight - 40
controlGroup.alpha=0.7

--event listener functions 
.
.
.


return controlGroup


[TOPIC: post.html]
#4

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 430 posts
  • Corona SDK

The require command loads the dpad module into memory but then it is not being called to do anything.  Where did you get the module from?  Can you post a link to it?



[TOPIC: post.html]
#5

karagozkenan

[GLOBAL: userInfoPane.html]
karagozkenan
  • Observer

  • 10 posts
  • Corona SDK

i wrote it  :(



[TOPIC: post.html]
#6

karagozkenan

[GLOBAL: userInfoPane.html]
karagozkenan
  • Observer

  • 10 posts
  • Corona SDK

--dpad.lua
local player=require"player"
 
local controlGroup = display.newGroup()
local Dpad = display.newImageRect(controlGroup, "assets/images/control.png", 128, 32)
Dpad.x = 80
Dpad.y = display.viewableContentHeight - 40
local jmp=display.newImageRect(controlGroup,"assets/images/jump.png",64,64)
jmp.x = display.viewableContentWidth- 50
jmp.y = display.viewableContentHeight - 40
controlGroup.alpha=0.7
 
 
 
local jump = function(event)
if event.phase == "began" then
display.getCurrentStage():setFocus(event.target, event.id)
event.target.isFocus = true
player:jump()
end
if event.phase == "ended" or event.phase == "cancelled" then
display.getCurrentStage():setFocus( event.target, nil )
event.target.isFocus = false
end
return true
end
 
 
local run = function(event)
  if event.phase == "began" then
display.getCurrentStage():setFocus(event.target, event.id)
event.target.isFocus = true
end
if event.phase == "began" or event.phase == "moved" then
if event.x < event.target.x then
player:run(-1)
end
if event.x > event.target.x then
player:run(1)
end
end
if event.phase == "ended" or event.phase == "cancelled" then
display.getCurrentStage():setFocus( event.target, nil )
event.target.isFocus = false
player:run(0)
end
return true
end
 
jmp:addEventListener("touch", jump)
Dpad:addEventListener("touch", run)
 
return controlGroup



[topic_controls]
[/topic_controls]